Skip to content

Order of destructor call of temporary and __cxa_throw #62062

Closed
@strimo378

Description

@strimo378

I might have found an issue with the order of destructor call of a temporary and the call to the __cxa_throw function within a throw statement.

In the following code, the Clang frontend first calls __cxa_throw and afterwards a::~a. See https://godbolt.org/z/jbx74s1Ge

struct a {
  ~a() noexcept;
};
struct b {
  b(a) noexcept;
};
void c() {throw b(a()); }

GCC generates it in opposite order which is more logical to me. ICC generates it in the same order as Clang. I don't know what is correct from the C++ standard, maybe it is undefined.

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:codegenIR generation bugs: mangling, exceptions, etc.questionA question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions