Bug with exceptions and g++ 2.95

Jim Nance jnance@nortelnetworks.com
Wed Aug 4 13:30:00 GMT 1999


Hello All,
    I think I have found a bug with g++ 2.95 runing under HP-UX 10.20 when
building mozilla.  The mozilla build process tries to compile a file using
the following command line:

/scratch/jnance/gnu/bin/g++ -v --save-temps -o nsBuffer.o -c
-fno-rtti -fno-exceptions -Wp,-MD,.deps/nsBuffer.pp -include
../../config-defs.h -g -fPIC -DDEBUG -UNDEBUG -DDEBUG_jnance -DTRACING
-DOSTYPE=\"HP-UXB.10\" -DNECKO -D_IMPL_NS_COM -D_IMPL_NS_BASE
-I../../dist/include -I../../dist/./include -I../../dist/include
-I/scratch/jnance/mozilla/mozilla/include
-I/scratch/jnance/mozilla/prefix/include -I../../dist/./public/jpeg
-I../../dist/./public/png -I../../dist/./public/zlib
-I/opt/corp/contrib/X11R6/include/
/scratch/jnance/mozilla/mozilla/xpcom/ds/nsBuffer.cpp

As you can see, the compiler is called with -fno-exceptions because mozilla
does not use exceptions.  Unfortunatly the compiler fails to compile this
file, producing these warnings (among others):

In file included from /scratch/jnance/mozilla/mozilla/xpcom/ds/nsBuffer.cpp:20:
../../dist/include/nsAutoLock.h: In function `static void * nsAutoLock::operator new(unsigned int)':
../../dist/include/nsAutoLock.h:95: operator new should throw an exception, not return NULL
In file included from /scratch/jnance/mozilla/mozilla/xpcom/ds/nsBuffer.cpp:20:
../../dist/include/nsAutoLock.h: In function `static void * nsAutoMonitor::operator new(unsigned int)':
../../dist/include/nsAutoLock.h:175: operator new should throw an exception, not return NULL
../../dist/include/nsAutoLock.h: In function `static void * nsAutoCMonitor::operator new(unsigned int)':
../../dist/include/nsAutoLock.h:232: operator new should throw an exception, not return NULL

Since the compiler has exceptions turned off, it seems wrong to require the
code throw an exception.  I am not a C++ expert so please forgive me if I have
misunderstood what is going on.

The code does compile with g++ 2.8.1

Thanks,

Jim


More information about the Gcc-bugs mailing list