[Bug c++/85363] Throwing exception from member constructor (brace initializer vs initializer list)

mpolacek at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Thu May 10 22:54:00 GMT 2018


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

--- Comment #6 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
P::P () is marked as TREE_NOTHROW because when we're processing X::X ((struct X
*) <<< Unknown tree: void_cst >>>, 20) (which can throw) in
set_flags_from_callee, cfun is null in this case, so we don't mark P::P() as
can_throw.

If struct P were
struct P {
    P () : x {5} {}
    X x;
};

it would work as expected, because when processing X::X(), cfun would be
non-null, so it would be marked as can_throw.


More information about the Gcc-bugs mailing list