This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
'false' should be a valid null pointer constant
- To: gcc-bugs at gcc dot gnu dot org
- Subject: 'false' should be a valid null pointer constant
- From: scott douglass <sdouglas at arm dot com>
- Date: Thu, 25 Nov 1999 15:26:23 +0000
The following code gives an error. It should be accepted (albeit a warning
would be a good idea since it's lousy code):
int *f() { return false; } // gives error: return to `int *' from `bool'
I think 'false' is "an integral constant expression rvalue of integer type
that evaluates to zero" (5.19). Issure #97 at
<http://anubis.dkuug.dk/JTC1/SC22/WG21/docs/core8.htm> agrees (although
it's thrust is slightly different).
command line: g++ -c bug.c
g++ -v says:
Reading specs from
/eda/tools/gnu/tools/egcs-1.1.2/sunos5.6/lib/gcc-lib/sparc-sun-solaris2.6/eg
cs-2.91.66/specs
gcc version egcs-2.91.66 19990314 (egcs-1.1.2 release)
This is not very important since the work-around is better code anyway.