Exception handling not working on 4.7.1
Zoltan Glozik
zoltan@epochcapital.com.au
Thu Sep 27 01:26:00 GMT 2012
> ...
> I have compiled gcc 4.7.1 from sources on SuSE 11 Enterprise SP1 and
> the following application calls terminate() instead of catching the
> exception, but it works as expected on the same platform with gcc
> 4.5:
>
> cpptest.cpp:
> ------------------------------------------
> int main()
> {
> try {
> throw 1;
> } catch (int) {
> // empty
> }
> return 0;
> }
> ------------------------------------------
>
> $ g++-4.7.1 -o cpptest cpptest.cpp
> $ ./cpptest
> terminate called after throwing an instance of 'int'
> Aborted (core dumped)
> $ g++-4.5 -o cpptest cpptest.cpp
> $ ./cpptest
> $
>
I have tried the latest gcc-4.7.2 release and it has the same problem, however, the --eh-frame-hdr linker option fixes it:
$ g++-4.7.2 -Wl,--eh-frame-hdr -o cpptest cpptest.cpp
$ ./cpptest
$
For some reason the --eh-frame-hdr option gets removed when I augment the built-in specs with the following <gcc_root>/spec file:
*link:
+ %{!m32:-rpath=/opt/epoch/lib64/gcc/x86_64-unknown-linux-gnu/4.7.2} %{!m32:-rpath=/opt/epoch/lib64/gcc/x86_64-unknown-linux-gnu/4.7.2/libgcc/lib64} %{m32:-rpath=/opt/epoch/lib64/gcc/x86_64-unknown-linux-gnu/4.7.2/32} %{m32:-rpath=/opt/epoch/lib64/gcc/x86_64-unknown-linux/4.7.2/libgcc/lib}
Given that I was using '+' on the link spec line I would not have expected it to remove any options from the built-in spec. Weird...
Zoltan
More information about the Gcc-help
mailing list