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

 
 

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

Submitted by:  Rik <rik5>
Submitted on:  Mon 24 Jul 2017 08:52:38 PM UTC  
 
Category: NoneSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Other
Status: FixedAssigned to: None
Originator Name: Open/Closed: Closed
Release: devOperating System: Any

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

(Jump to the original submission 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>
Project 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>
Project 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

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>
Project 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>
Project 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>
Project Administrator
Mon 24 Jul 2017 09:35:18 PM UTC, comment #1:

I did

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

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>
Project Administrator

 

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

Attach File(s):
   
   
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
  • -unavailable- added by jwe (Posted a comment)
  • -unavailable- added by dasergatskov (Updated the item)
  • -unavailable- added by rik5 (Submitted the item)
  • -unavailable- added by rik5
  • -unavailable- added by rik5
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 8 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Thu 27 Jul 2017 03:50:05 PM UTCrik5StatusIn Progress=>Fixed
      Open/ClosedOpen=>Closed
    Thu 27 Jul 2017 12:11:13 AM UTCdasergatskovAttached File-=>Added gcc_err_20170726.log.bz2, #41354
      Attached File-=>Added gcc_min_err_20170726.log, #41355
    Tue 25 Jul 2017 10:40:38 PM UTCdasergatskovAttached File-=>Added gcc_err_20170725.log.bz2, #41337
    Mon 24 Jul 2017 09:35:18 PM UTCdasergatskovAttached File-=>Added gcc_err_20170724.log.bz2, #41323
    Mon 24 Jul 2017 08:52:38 PM UTCrik5Carbon-Copy-=>Added jwe
      Carbon-Copy-=>Added dasergatskov

    Back to the top


    Powered by Savane 3.1-cleanup1