bugGNU Octave - Bugs: bug #51565, Use nullptr rather than 0 in C++11...

 
 

bug #51565: Use nullptr rather than 0 in C++11 code

Submitter:  Rik <rik5>
Submitted:  Mon 24 Jul 2017 08:52:38 PM UTC
   
 
Category:  None Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Other
Status:  Fixed Assigned to:  None
Originator Name:  Open/Closed:  * Closed
Release:  * dev Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Thu 27 Jul 2017 04:08:05 PM UTC, comment #10: 

Confirm. All I can see are Qt5 and GM warnings.

Dmitri.
--

Dmitri A. Sergatskov <dasergatskov>
Thu 27 Jul 2017 03:50:05 PM UTC, comment #9: 

Finally, this should be it.  Last changeset for nullptr checked in here (http://hg.savannah.gnu.org/hgweb/octave/rev/771310737137).

There still may be instances that have not been discovered because of the way we are using the compiler to check.  I noticed that there were some spots in the code with #if defined / #else blocks where both blocks had function calls that were making use of 0 rather than nullptr.  GCC only reports on the code that was actually compiled so one of the branches was always being missed.  I changed the code if I noticed the block, but I might have overlooked some.

Anyways, marking as fixed and closing report.

Rik <rik5>
Group administrator
Thu 27 Jul 2017 12:34:33 AM UTC, comment #8: 

The warning about 'fw' was in the last log.  It is definitely real and I am going to fix it in a separate changeset from those that deal with nullptr issues.

Rik <rik5>
Group administrator
Thu 27 Jul 2017 12:11:13 AM UTC, comment #7: 

I noticed that many of those warnings come from Qt headers.
So i compiled a minimal version with

../configure --disable-java --disable-docs --without-qt --without-fltk CXXFLAGS="-g -O2 -Wzero-as-null-pointer-constant -Wno-noexcept-type -Wno-implicit-fallthrough"


attached as gcc_min_err_20170726.log

Also attached the default build error log, gcc_err_20170726.log.bz2

Also noticed a new warning:
../libinterp/corefcn/pr-output.cc:1749:29: warning: ‘fw’ may be used uninitialized in this function [-Wmaybe-uninitialized]
       int column_width = fw + 2;
                          ~~~^~~

Dmitri.
--


(file #41354, file #41355)

Dmitri A. Sergatskov <dasergatskov>
Wed 26 Jul 2017 11:30:28 PM UTC, comment #6: 

I pushed another cset to address instances of 0 which should be nullptr (http://hg.savannah.gnu.org/hgweb/octave/rev/4f12819a634f).  We should be very close now to zero warnings.

Rik <rik5>
Group administrator
Tue 25 Jul 2017 10:40:38 PM UTC, comment #5: 

There are few left...

Attached.


(file #41337)

Dmitri A. Sergatskov <dasergatskov>
Tue 25 Jul 2017 10:04:15 PM UTC, comment #4: 

@Dmitri: I checked in a huge change which converts most instances of '0' to "nullptr".  See http://hg.savannah.gnu.org/hgweb/octave/rev/980f39c3ab90.

I'm sure there are instances I missed since the log file I was working from was 11 MB.  Could you re-compile and generate a new report of the remaining instances that need fixing?

Rik <rik5>
Group administrator
Mon 24 Jul 2017 10:03:27 PM UTC, comment #3: 

Either way is fine with me.
BTW, clang-tidy (as of 3.8 I think) has modernize-use-nullptr.
Perhaps it could be useful.

https://www.kdab.com/clang-tidy-part-1-modernize-source-code-using-c11c14/

Dmitri.
--

Dmitri A. Sergatskov <dasergatskov>
Mon 24 Jul 2017 09:40:46 PM UTC, comment #2: 

If we succeed in getting a clean build with this flag, it could be added to the default warning options that we use, so then it wouldn't be specific to a particular buildbot config.

John W. Eaton <jwe>
Group administrator
Mon 24 Jul 2017 09:35:18 PM UTC, comment #1: 

I did

../configure CXXFLAGS="-O2 -Wzero-as-null-pointer-constant"
make -j8 V=1 1>gcc_20170724.log 2>gcc_err_20170724.log


gcc_err_20170724.log is 11MB

Attached gcc_err_20170724.log.bz2

If it could be useful, jwe can add this flag to fedora gcc buildbot.

HG ID 2641a0196176 tip @

Dmitri.
--


(file #41323)

Dmitri A. Sergatskov <dasergatskov>
Mon 24 Jul 2017 08:52:38 PM UTC, original submission:  

In C++11 programmer's can use 'nullptr' rather than 0, or the macro NULL, to indicate an invalid pointer.  This has better type safety, and it is clearer what the programmer meant.

It would be good to convert Octave's use of 0 to nullptr.  GCC 7 has a new warning option, -Wzero-as-null-pointer-constant, which helps find instances of 0 which could be converted.  The documentation is


-Wzero-as-null-pointer-constant (C++ and Objective-C++ only)
Warn when a literal ‘0’ is used as null pointer constant. This can be useful to
facilitate the conversion to nullptr in C++11.


I do not have access to GCC 7 so I am posting this bug report and request.  Could someone (Dmitri?) set CXXFLAGS to include -Wzero-as-null-pointer-constant and then re-compile all of Octave while saving the compile log?  If you upload the log I can then take care of changing the instances.

Rik <rik5>
Group administrator

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #41354:  gcc_err_20170726.log.bz2 added by dasergatskov (12KiB - application/x-bzip)
file #41337:  gcc_err_20170725.log.bz2 added by dasergatskov (32KiB - application/x-bzip)
file #41323:  gcc_err_20170724.log.bz2 added by dasergatskov (133KiB - application/x-bzip)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by jwe (Posted a comment)
  • -email is unavailable- added by dasergatskov (Updated the item)
  • -email is unavailable- added by rik5 (Submitted the item)
  • -email is unavailable- added by rik5
  • -email is unavailable- added by rik5
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 8 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2017-07-27 rik5 StatusIn Progress Fixed
        Open/ClosedOpen Closed
    2017-07-27 dasergatskov Attached File- Added gcc_err_20170726.log.bz2, #41354
        Attached File- Added gcc_min_err_20170726.log, #41355
    2017-07-25 dasergatskov Attached File- Added gcc_err_20170725.log.bz2, #41337
    2017-07-24 dasergatskov Attached File- Added gcc_err_20170724.log.bz2, #41323
    2017-07-24 rik5 Carbon-Copy- Added jwe
        Carbon-Copy- Added dasergatskov

    Back to the top

    Powered by Savane 3.13-d3ae.
    Corresponding source code