This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

'false' should be a valid null pointer constant


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]