This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Exception handling not working on 4.7.1
- From: Zoltan Glozik <zoltan at epochcapital dot com dot au>
- To: gcc-help at gcc dot gnu dot org
- Date: Thu, 27 Sep 2012 11:25:40 +1000 (EST)
- Subject: Re: Exception handling not working on 4.7.1
> ...
> 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