public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/114571] New: -Wzero-as-null-pointer-constant does not complain about NULL
@ 2024-04-03 9:26 ossman at cendio dot se
2024-04-03 9:29 ` [Bug c++/114571] " ossman at cendio dot se
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: ossman at cendio dot se @ 2024-04-03 9:26 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114571
Bug ID: 114571
Summary: -Wzero-as-null-pointer-constant does not complain
about NULL
Product: gcc
Version: 13.2.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: ossman at cendio dot se
Target Milestone: ---
Created attachment 57857
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=57857&action=edit
Test case
We are looking at bringing up the TigerVNC project to a more modern C++ style,
and one thing was using nullptr instead of NULL. We were very glad when we
found -Wzero-as-null-pointer-constant to help out with this.
Unfortunately, it doesn't seem to do much for NULL in modern¹ gcc. It spots
usage of "0", but not any "NULL". clang has no trouble finding both.
I've attached a test case with some comments on the cases we've seen.
¹ gcc 5 spots some, but not all NULL
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/114571] -Wzero-as-null-pointer-constant does not complain about NULL
2024-04-03 9:26 [Bug c++/114571] New: -Wzero-as-null-pointer-constant does not complain about NULL ossman at cendio dot se
@ 2024-04-03 9:29 ` ossman at cendio dot se
2024-04-03 11:29 ` ossman at cendio dot se
2024-04-03 14:19 ` ossman at cendio dot se
2 siblings, 0 replies; 4+ messages in thread
From: ossman at cendio dot se @ 2024-04-03 9:29 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114571
--- Comment #1 from Pierre Ossman <ossman at cendio dot se> ---
Hmm.. I found bug 77513, and r9-873. So I guess this is intentional?
This makes the warning somewhat pointless. We want to make sure developers
standardise on nullptr, both for style and since the behaviour of NULL is
compiler dependent (if I'm understanding the C++ standard correctly).
It's also annoying if there is not a consensus between clang and gcc here.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/114571] -Wzero-as-null-pointer-constant does not complain about NULL
2024-04-03 9:26 [Bug c++/114571] New: -Wzero-as-null-pointer-constant does not complain about NULL ossman at cendio dot se
2024-04-03 9:29 ` [Bug c++/114571] " ossman at cendio dot se
@ 2024-04-03 11:29 ` ossman at cendio dot se
2024-04-03 14:19 ` ossman at cendio dot se
2 siblings, 0 replies; 4+ messages in thread
From: ossman at cendio dot se @ 2024-04-03 11:29 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114571
--- Comment #2 from Pierre Ossman <ossman at cendio dot se> ---
Found another case that neither gcc 5, gcc 13, nor clang complain about for
some odd reason:
> assert(thing == NULL);
All three complain about:
> assert(thing == 0);
Not sure what's going on here.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/114571] -Wzero-as-null-pointer-constant does not complain about NULL
2024-04-03 9:26 [Bug c++/114571] New: -Wzero-as-null-pointer-constant does not complain about NULL ossman at cendio dot se
2024-04-03 9:29 ` [Bug c++/114571] " ossman at cendio dot se
2024-04-03 11:29 ` ossman at cendio dot se
@ 2024-04-03 14:19 ` ossman at cendio dot se
2 siblings, 0 replies; 4+ messages in thread
From: ossman at cendio dot se @ 2024-04-03 14:19 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114571
--- Comment #3 from Pierre Ossman <ossman at cendio dot se> ---
And another odd case; gcc 5 complains about this:
> const char *a;
> a = NULL;
but not:
> const char *a = NULL;
gcc 13 complains about neither, and clang about both.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-04-03 14:19 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-03 9:26 [Bug c++/114571] New: -Wzero-as-null-pointer-constant does not complain about NULL ossman at cendio dot se
2024-04-03 9:29 ` [Bug c++/114571] " ossman at cendio dot se
2024-04-03 11:29 ` ossman at cendio dot se
2024-04-03 14:19 ` ossman at cendio dot se
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).