This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Exception-Catching with gcc 4.x does not work on SunOS SPARC
- From: Matthias Apitz <guru at unixarea dot de>
- To: gcc-help at gcc dot gnu dot org
- Date: Tue, 6 Oct 2015 14:26:40 +0200
- Subject: Exception-Catching with gcc 4.x does not work on SunOS SPARC
- Authentication-results: sourceware.org; auth=none
- Reply-to: Matthias Apitz <guru at unixarea dot de>
Hello,
We learned that the exception handling in our application-servers (C++
written) does not work. We reduced the problem to the following example
code:
#include <iostream>
using namespace std;
int main(int argc, const char **argv)
{
cout << "work:Start" << endl;
try {
throw 7;
}
catch (int ex) {
cout << "Caught exception int: " << ex << endl;
}
catch (...) {
cout << "Caught exception ..." << endl;
}
cout << "work:Ende" << endl;
}
and compile it with:
$ uname -a
SunOS srap01dxle 5.10 Generic_150400-17 sun4u sparc SUNW,SPARC-Enterprise
$ /usr/local/gcc-492/bin/gcc -v
Using built-in specs.
COLLECT_GCC=/usr/local/gcc-492/bin/gcc
COLLECT_LTO_WRAPPER=/usr/local/gcc-492/libexec/gcc/sparc-sun-solaris2.10/4.9.2/lto-wrapper
Target: sparc-sun-solaris2.10
Configured with: ./configure --prefix=/usr/local/gcc-492 --with-gmp=/usr/local/gmp-600 --with-mpfr=/usr/local/mpfr-313 --with-mpc=/usr/local/mpc-102 --without-isl --without-cloog
Thread model: posix
gcc version 4.9.2 (GCC)
$ /usr/local/gcc-492/bin/gcc -o work work.C -L/usr/local/gcc-492/lib -lstdc++
$ ldd ./work
libstdc++.so.6 => /usr/local/gcc-492/lib/libstdc++.so.6
libc.so.1 => /lib/libc.so.1
libm.so.2 => /lib/libm.so.2
librt.so.1 => /lib/librt.so.1
libgcc_s.so.1 => /usr/local/gcc-492/lib/libgcc_s.so.1
libaio.so.1 => /lib/libaio.so.1
libmd.so.1 => /lib/libmd.so.1
/platform/SUNW,SPARC-Enterprise/lib/libc_psr.so.1
/lib/libm/libm_hwcap1.so.2
$ ./work
work:Start
terminate called after throwing an instance of 'int'
Abort - core dumped
The same code works fine on Linux and FreeBSD:
$ gcc48 -o work work.cc -lstdc++ ; ./work
work:Start
Caught exception int: 7
work:Ende
$ g++48 -o work work.cc -lstdc++ ; ./work
work:Start
Caught exception int: 7
work:Ende
$ clang -o work work.cc -lstdc++ ; ./work
work:Start
Caught exception int: 7
work:Ende
'clang' is the new standard compiler in FreeBSD from http://clang.llvm.org
Any idea about the problem?
Thanks
matthias
--
Matthias Apitz, â guru@unixarea.de, ð http://www.unixarea.de/ â +49-176-38902045