Crash with C++exception. Bug in codegen, or in the developer ?

Hello,

While running the following code, it crashes due to an invalid free operation:

exc(8657) malloc: *** error for object 0x7f97c14039e0: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
fish: Job 1, ‘./exc’ terminated by signal SIGABRT (Abort)


#include

class Error {
public:
explicit inline Error(const std::string &str) noexcept {}
};

std::string _cxx_strfmt() noexcept { return std::string(); }

int main(int argc, char **argv) {
try {
throw Error(_cxx_strfmt());
} catch (…) {}
}

exc.s (5.25 KB)

exc-crash.s (5.33 KB)

It’s a clang bug; somehow we’re unconditionally freeing the exception
in this case.

John.

Thanks, I filled it as Bug 13359

– Jean-Daniel