https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64181

            Bug ID: 64181
           Summary: 'noexcept' on a lambda sometimes appears to get
                    optimised away at -O2 (or above).
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: rogero at howzatt dot demon.co.uk

Created attachment 34188
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=34188&action=edit
Demonstration of the problem

In some cases a program containing noexcept on a lambda allows exceptions
thrown inside the body of the lambda to propagate out of the lambda.

We have managed to simplify the problem down to a small test case (attached as
noexcept_optimisation_bug.cpp) - the issue seems to occur when the lambda is
called inside a virtual function and in turns calls a virtual function.

The example contains a 'volatile' pointer -- the original code used a shared
pointer here, it seems that you just need "enough" here to prevent the
optimiser remove the function completely.

Reply via email to