[Bug tree-optimization/66738] New: [5/6 Regression] optimizer bug related to exceptions and static symbols
doko at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Thu Jul 2 12:34:00 GMT 2015
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66738
Bug ID: 66738
Summary: [5/6 Regression] optimizer bug related to exceptions
and static symbols
Product: gcc
Version: 5.1.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: doko at gcc dot gnu.org
Target Milestone: ---
[forwarded from https://bugs.debian.org/788299]
seen with the gcc-5-branch 20150625 and trunk 20150610 (r224324)
$ g++-5 -g -O2 code.cpp && ./a.out
Segmentation fault (core dumped)
$ g++-5 -g -O0 code.cpp && ./a.out
terminate called after throwing an instance of 'MyException'
what(): MyException: No!
Aborted (core dumped)
$ g++-4.9 -g -O2 code.cpp && ./a.out
terminate called after throwing an instance of 'MyException'
what(): MyException: No!
Aborted (core dumped)
$ cat code.cpp
#include <exception>
#include <string>
class MyException : public std::exception
{
protected:
typedef std::exception Parent;
public:
MyException(const char* cStr): Parent(), m_reason(cStr) {
updateMessage();
}
virtual ~MyException() throw() {}
virtual const std::string& exceptionName() const {
return exceptionNameValue;
}
virtual const char* what() const throw() {
return m_exceptionMessage.c_str();
}
inline void updateMessage() {
m_exceptionMessage = exceptionName() + ": " + m_reason;
}
private:
std::string m_reason;
std::string m_exceptionMessage;
static const std::string exceptionNameValue;
};
const std::string MyException::exceptionNameValue("MyException");
int main() {
throw MyException("No!");
return 0;
}
More information about the Gcc-bugs
mailing list