http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60125

            Bug ID: 60125
           Summary: defaulted constructor with throwing NSDMI still
                    declared as noexcept
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: harald at gigawatt dot nl

struct S {
  int i = (throw 0, 0);
  S() = default;
};
int main() {
  try {
    S();
  } catch(int i) {
    return i;
  }
}

The constructor for S is marked noexcept, and as a result, the exception thrown
from i's initialiser cannot be caught, and this program aborts.

This seems to be exactly what the standard requires: [except.spec]p14 says that
the noexcept specification depends only on the functions invoked by the
constructor. However, I'm reporting it anyway at the request of Marc Glisse,
who says it's worth reporting even if it's a bug in the standard
(http://stackoverflow.com/a/21660078/743382).

Reply via email to