4.7.2: not catching exceptions on Solaris 64bit?

Carsten Aulbert gcc-help@miyameca.de
Wed Feb 13 08:45:00 GMT 2013


Hi

a colleague of mine found something werid on Solaris 10 with a recent
gcc instaleld via blastwave:

g++ -v
Reading specs from /opt/csw/lib/gcc/i386-pc-solaris2.10/4.7.2/specs
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/opt/csw/libexec/gcc/i386-pc-solaris2.10/4.7.2/lto-wrapper
Target: i386-pc-solaris2.10
Configured with:
/home/maciej/src/opencsw/pkg/gcc4/trunk/work/solaris10-i386/build-isa-pentium_pro/gcc-4.7.2/configure
--prefix=/opt/csw --exec_prefix=/opt/csw --bindir=/opt/csw/bin
--sbindir=/opt/csw/sbin --libexecdir=/opt/csw/libexec
--datadir=/opt/csw/share --sysconfdir=/etc/opt/csw
--sharedstatedir=/opt/csw/share --localstatedir=/var/opt/csw
--libdir=/opt/csw/lib --infodir=/opt/csw/share/info
--includedir=/opt/csw/include --mandir=/opt/csw/share/man
--enable-cloog-backend=isl --enable-java-awt=xlib
--enable-languages=ada,c,c++,fortran,go,java,objc --enable-libada
--enable-libssp --enable-nls --enable-objc-gc --enable-threads=posix
--program-suffix=-4.7 --with-cloog=/opt/csw --with-gmp=/opt/csw
--with-included-gettext --with-ld=/usr/ccs/bin/ld --without-gnu-ld
--with-libiconv-prefix=/opt/csw --with-mpfr=/opt/csw --with-ppl=/opt/csw
--with-system-zlib=/opt/csw --with-gnu-as --with-as=/opt/csw/bin/gas
Thread model: posix
gcc version 4.7.2 (GCC)


the test case

$ cat test.cpp
#include <cstdlib>
#include <stdexcept>

int
main(int, char**)
{
  try {
    throw std::runtime_error("Some error");
  }
  catch(const std::exception &e )
    {
      exit( 0 );
    }
  exit( 1 );
}

works as expected on 32bit builds:

$ g++ -m32 test.cpp && ./a.out ; echo $?
0

$ ldd ./a.out
        libstdc++.so.6 =>        /opt/csw/lib/libstdc++.so.6
        libm.so.2 =>     /lib/libm.so.2
        libgcc_s.so.1 =>         /opt/csw/lib/libgcc_s.so.1
        libc.so.1 =>     /lib/libc.so.1

however, the 64bit build does not catch the exception:

$ g++ -m64 test.cpp && ./a.out ; echo $?
terminate called after throwing an instance of 'std::runtime_error'
terminate called recursively
Abort (core dumped)
134

$ ldd ./a.out
        libstdc++.so.6 =>        /opt/csw/lib/64/libstdc++.so.6
        libm.so.2 =>     /lib/64/libm.so.2
        libgcc_s.so.1 =>         /opt/csw/lib/64/libgcc_s.so.1
        libc.so.1 =>     /lib/64/libc.so.1

Is this expected? (I'm more admin than programmer and C++ is not really
my area of expertise)

Any pointer/help is appreciated where to find on this topic.

Thanks a lot in advance!

Cheers

Carsten



More information about the Gcc-help mailing list