[cfe-dev] Crash with C++exception. Bug in codegen, or in the developer ?
Jean-Daniel Dupas
devlists at shadowlab.org
Fri Jul 13 12:17:09 PDT 2012
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 <string>
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 (...) {}
}
------
compiled using
clang++ -std=c++11 exc.cpp
I can't see what is wrong with this code, but if I remove the noexcept declaration (either one), it stop crashing and run as expected.
Is this something I'm doing wrong, or this is a subtle clang bug ?
I attach the llvm ir generate with noexcept (exc-crash.s) and the one without (exc.s)
If this is a bug in clang, tell me, I will fill a report.
Thanks
-- Jean-Daniel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20120713/6d145b7a/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: exc.s
Type: application/octet-stream
Size: 5378 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20120713/6d145b7a/attachment.obj>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20120713/6d145b7a/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: exc-crash.s
Type: application/octet-stream
Size: 5462 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20120713/6d145b7a/attachment-0001.obj>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20120713/6d145b7a/attachment-0002.html>
More information about the cfe-dev
mailing list