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]
Other format: [Raw text]

[Bug c++/14644] New: enum of value zero not converted to (null) pointer


The following code should compile since NULL is a constant expression which 
evaluates to zero. NULL is also an rvalue -- so the questioned reasoning under 
bug 13867 cannot be used.

# 1 "test2.cc"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "test2.cc"
enum {NULL = 0};

void f(int*);

int main()
{
  f(NULL);
}

Instead the following error message is generated:

test2.cc: In function `int main()':
test2.cc:7: error: cannot convert `<anonymous enum>' to `int*' for argument `1'
   to `void f(int*)'

Compiler used is:

~>g++ -v
Reading specs from /usr/lib/gcc-lib/i686-pc-cygwin/3.3.1/specs
Configured with: /GCC/gcc-3.3.1-3/configure --with-gcc --with-gnu-ld --with-
gnu-as --prefix=/usr --exec-prefix=/usr --sysconfdir=/
etc --libdir=/usr/lib --libexecdir=/usr/sbin --mandir=/usr/share/man --
infodir=/usr/share/info --enable-languages=c,ada,c++,f77,pa
scal,java,objc --enable-libgcj --enable-threads=posix --with-system-zlib --
enable-nls --without-included-gettext --enable-interpre
ter --enable-sjlj-exceptions --disable-version-specific-runtime-libs --enable-
shared --disable-win32-registry --enable-java-gc=boe
hm --disable-hash-synchronization --verbose --target=i686-pc-cygwin --
host=i686-pc-cygwin --build=i686-pc-cygwin
Thread model: posix
gcc version 3.3.1 (cygming special)

-- 
           Summary: enum of value zero not converted to (null) pointer
           Product: gcc
           Version: 3.3.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: llewins at raytheon dot com
                CC: gcc-bugs at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14644


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