[Bug c++/35669] NULL (__null) not considered different from 0 with C++
l dot lunak at suse dot cz
gcc-bugzilla@gcc.gnu.org
Sun Feb 14 21:47:00 GMT 2010
------- Comment #18 from l dot lunak at suse dot cz 2010-02-14 21:47 -------
(In reply to comment #17)
> Which one? We are not going to warn for conversions to boolean and we are not
> going to warn for explicit conversions.
I don't see anybody asking for that.
> And we are not going to warn by default, only with -Wconversion.
If you fail to see the difference between NULL being converted to integer
being almost always a mistake and the flood of warnings caused by -Wcoversion
to be almost almost harmless in real-world code, then you probably might as
well not bother at all. A warning about something that's almost for sure a
mistake being part of a flag that almost nobody uses is next to useless.
> So, please post a testcase as minimal and self-contained (with the smallest
> number of includes) as possible and point out
> exactly what you expect to happen.
Well, it's all in the original comment of this bugreport, but if you insist:
Testcase (a.c):
#include <stddef.h>
void foo( int a );
int main()
{
foo( NULL );
foo( 0 );
int a = NULL;
return 0;
}
Expected output (like 'gcc -Wall -c a.c' provides):
a.c: In function ‘main’:
a.c:5: warning: passing argument 1 of ‘foo’ makes integer from
pointer without a cast
a.c:2: note: expected ‘int’ but argument is of type ‘void
*’
a.c:7: warning: initialization makes integer from pointer without a cast
a.c:7: warning: unused variable ‘a’
Actual output (what 'g++ -Wall -c a.c' provides):
a.c: In function ‘int main()’:
a.c:7: warning: unused variable ‘a’
The warning about the unused variable is obviously irrelevant.
--
l dot lunak at suse dot cz changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|WAITING |UNCONFIRMED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35669
More information about the Gcc-bugs
mailing list