This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Non-call-exceptions, unwinding and g++ optimization levels
- From: Richard Biener <richard dot guenther at gmail dot com>
- To: Jorge BellÃn Castro <jbelloncastro at gmail dot com>
- Cc: GCC Development <gcc at gcc dot gnu dot org>
- Date: Wed, 21 Jan 2015 13:28:59 +0100
- Subject: Re: Non-call-exceptions, unwinding and g++ optimization levels
- Authentication-results: sourceware.org; auth=none
- References: <CAHj0YyAvUJHLds8jAZ+3T-gTDUKM3qaQh4KRJexhrKDvqPpdfQ at mail dot gmail dot com>
On Wed, Jan 21, 2015 at 12:13 PM, Jorge BellÃn Castro
<jbelloncastro@gmail.com> wrote:
> Good day,
> I'm working with exceptions thrown by a signal handler using
> -fnon-call-exceptions flag with g++ for x86_64.
>
> The problem I am facing is that the behavior of this mechanism is not
> consistent if we change some optimization options, that is, the result
> of a given program can be different. In order to make a comparison, I
> ran this test several times, each with different optimizations
> enabled.
>
> Compilation either with -O0 or without any flags (just -fnon-call-exceptions):
> Exception is caught at the "copy" function (the one which calls
> std::copy). This is the expected behavior.
>
> Compilation using -O1 -O2 or -O3 flag directly:
> Exception is not being caught.
>
> If both -fno-inline and -fno-ipa-pure-const are used, then the program
> behaves as if -O0 is used. Thus, I tried to add
> __attribute__((noinline)) to both "foo" and "copy" functions. It seems
> that they were ignored because the problem doesn't dissapear when
> -fno-inline is not used.
>
> In my opinion, it seems that catch blocks are being optimized out or
> that, because of the inlining, the generated code is not able to find
> any catch blocks inside its scope.
>
> I could reproduce this with g++ versions 4.7.3, 4.8.1 and the latest
> in the public, read-only, git. The file used to test this is attached
> to the message. Compile command used is:
> g++ -fnon-call-exceptions [-fno-inline -fno-ipa-pure-const] -O{0,1,2,3}
Please open a bugreport.
Thanks,
Richard.
> Regards,
> Jorge