Re: zero-as-null-pointer-constant C++ trunk

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi!

On 22/05/2019 15:25, Jonathan Wakely wrote:
On Wed, 22 May 2019 at 15:12, Jonny Grant <jg@xxxxxxxx> wrote:

Hello

This is a little test case. It is not real code.

We used gcc-8 to get some warnings, but on the godbolt trunk gcc doesn't
those warnings with this little test case. Am I missing something
obvious? Is this an issue?

with gcc-8 only (1) of the (3) occurrences of NULL is warned.

Why do you want a warning for use of NULL?

To warn any use of 'NULL' macro in C++ code, and ensure 'nullptr' is used.

Does g++ have another way to warn for 'NULL'?

https://gcc.gnu.org/r260973 stopped GCC from giving that warning for
uses of NULL, because it's not a literal zero.

ah ok. That's a shame, it only warns for this now:
  ptr = 0;


https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html

"-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."


Perhaps the manual options page could clarify ?
"This will not warn any 'NULL' usage."

Cheers, Jonny



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux