Possible bug in g++: 0U == 0 == NULL?

Branko Cibej branko.cibej@hermes.si
Tue Aug 31 23:20:00 GMT 1999


Joerg Pommnitz wrote:

> The following small test case fails to compile with
> gcc-2.95:

[snip]

> The compiler complains that
> test.cc: In function `int main()':
> test.cc:12: call of overloaded `foo (unsigned int)' is ambiguous
> test.cc:2: candidates are: void foo(void *)
> test.cc:6:                 void foo(short unsigned int)
>
> Note that the argument is 0U and those marked not
> to be a pointer...

It is written:

     4.10 Pointer Conversions [conv.ptr]
     1   A _null pointer constant_ is an integral constant expression
         (5.19) rvalue of integer type that evaluates to zero. A null
         pointer  constant  can be  converted to a  pointer type; the
         result is a _null pointer value_ of that type ...

GCC is right. BTW, that's an *old* C++ FAQ.

    Brane

--
Branko Čibej                 <branko.cibej@hermes.si>
HERMES SoftLab, Litijska 51, 1000 Ljubljana, Slovenia
voice: (+386 61) 186 53 49   fax: (+386 61) 186 52 70




More information about the Gcc mailing list