Bug 100157 - Compilling with gcc flag -Wzero-as-null-pointer-constant triggers warnings
Summary: Compilling with gcc flag -Wzero-as-null-pointer-constant triggers warnings
Status: RESOLVED FIXED
Alias: None
Product: cppunit
Classification: Unclassified
Component: General (show other bugs)
Version:
(earliest affected)
1.13
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-05-31 09:11 UTC by GARCIN David
Modified: 2017-05-01 18:50 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments
Patch proposal (5.31 KB, application/mbox)
2016-05-31 09:11 UTC, GARCIN David
Details

Note You need to log in before you can comment on or make changes to this bug.
Description GARCIN David 2016-05-31 09:11:58 UTC
Created attachment 125410 [details]
Patch proposal

I'm currently building our project with gcc 5.2.

Using cppunit cppunit/extensions/HelperMacros.h header with gcc flag -Wzero-as-null-pointer-constant triggers warnings:

[...]include/cppunit/extensions/HelperMacros.h:171:31: error: zero as null
pointer constant [-Werror=zero-as-null-pointer-constant]
  CppUnitExDeleter() : suite (0) {}           \
                              ^

[...]include/cppunit/extensions/HelperMacros.h:174:45: error: zero as null
pointer constant [-Werror=zero-as-null-pointer-constant]
   CPPUNIT_NS::TestSuite *tmp = suite; suite = NULL; return tmp;  \
                                                ^

As stated in gcc documentation, this warning is used to facilitate the conversion to nullptr in C++11 [1]

Using nullptr is the c++11 way to initialize pointers with null value [2].

I've created a patch for the branch feature/c++11.

[1] https://gcc.gnu.org/onlinedocs/gcc-5.2.0/gcc/Warning-Options.html
[2] http://en.cppreference.com/w/cpp/language/nullptr
Comment 1 Aron Budea 2016-10-10 18:39:13 UTC
Confirmed.
Comment 2 Markus Mohrhard 2016-10-15 15:05:56 UTC
Pushed to the c++11 branch as https://cgit.freedesktop.org/libreoffice/cppunit/commit/?h=feature/c%2b%2b11

Note that I will most likely remove this class in a follow-up commit as it can be replaced by std::unique_ptr

Thanks a lot for your patch.
Comment 3 Markus Mohrhard 2016-10-15 15:12:09 UTC
That was a bad link. The correct one is https://cgit.freedesktop.org/libreoffice/cppunit/commit/?h=feature/c%2b%2b11&id=c2bb6da6cf469e44129ccc9f13e60e74d3cedef4


And the whole class has been removed with https://cgit.freedesktop.org/libreoffice/cppunit/commit/?h=feature/c%2b%2b11&id=840675f45d1245732b0f3ae5c1a5b4fc5fffec7b


Currently it looks like this branch will make it into the next release. C++11 support is mature enough in all browsers to be used as default.
Comment 4 Markus Mohrhard 2017-05-01 18:50:49 UTC
Cppunit 1.14 with this improvement has been released.