$ g++-mp-4.6 -Wconversion-null -c test.cc dhcp-172-19-248-71:~/tmp$ cat test.cc void foo(int* p); void bar() { const bool kDebugMode = false; // NULL pointer constant. foo(kDebugMode); // But no warning! } $ g++-mp-4.6 -Wconversion-null -c test.cc $ Changing the kDebugMode to 'false' or a false expression involving an enum triggers the warning.
Interestingly, in C++0x mode it works, obviously thanks to the work on constexpr. Do you really want it for C++98 too? ;)
Oops, sorry, got confused, in C++0x it's an hard error. Uhmmm.
On it.
Author: paolo Date: Fri Nov 4 16:31:18 2011 New Revision: 180963 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=180963 Log: /cp 2011-11-04 Paolo Carlini <paolo.carlini@oracle.com> PR c++/48420 * call.c (conversion_null_warnings): For 'false' to NULL pointer, just check that TREE_TYPE (expr) is a BOOLEAN_TYPE. /testsuite 2011-11-04 Paolo Carlini <paolo.carlini@oracle.com> PR c++/48420 * g++.dg/warn/Wconversion-null-3.C: New. Added: trunk/gcc/testsuite/g++.dg/warn/Wconversion-null-3.C Modified: trunk/gcc/cp/ChangeLog trunk/gcc/cp/call.c trunk/gcc/testsuite/ChangeLog
Fixed for 4.7.0.
*** Bug 51531 has been marked as a duplicate of this bug. ***
*** Bug 53207 has been marked as a duplicate of this bug. ***