This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/35669] NULL (__null) not considered different from 0 with C++
- From: "l dot lunak at suse dot cz" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 22 Mar 2008 23:15:30 -0000
- Subject: [Bug c++/35669] NULL (__null) not considered different from 0 with C++
- References: <bug-35669-14453@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #2 from l dot lunak at suse dot cz 2008-03-22 23:15 -------
When you say the warning is wrong, you presumably mean "passing argument 1 of
?foo? makes integer from pointer without a cast", but this bugreport is about
(the absence of) "passing NULL to non-pointer argument 1 of ?void foo(int)?",
which is a valid warning. I think nobody in their right mind would try to feed
NULL to foo(int), they should use 0 if they want an integer - why would NULL be
__null then instead of 0?
Using -Wconversion helps with getting the warning, but it also causes warnings
for normal common things like foo(2*0.5). While foo(NULL) is almost certainly a
bug somewhere (and I saw such one for real myself), foo(2*0.5) is quite common,
almost always harmless, and would require making the code more ugly by using
explicit casts.
Would it be possible to get a warning about an almost certain bug without many
warnings about something almost certainly harmless?
--
l dot lunak at suse dot cz changed:
What |Removed |Added
----------------------------------------------------------------------------
Severity|normal |enhancement
Status|RESOLVED |UNCONFIRMED
Resolution|WORKSFORME |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35669