Skip to content

Conversation

@Peter-Levine
Copy link
Owner

Building with >=C++11 (e.g., GCC-6), throwing an uncaught exception from within a destructor is generally considered dangerous and, when -Werror=terminate is forced in CXXFLAGS (as can be with Gentoo Linux, see bug 612978) it will break the compile. tl_assert() macro is expanded in some destructors (e.g., Child::~Child() from "src/unit_tests/tlXMLParser.cc"). Since function attribute [[noreturn]] is defined for >=C++11, better to use that instead of throw int(0).

Building with >=C++11 (e.g., GCC-6), throwing an uncaught exception from within a destructor is considered dangerous and, when "-Werror=terminate" is used in CXXFLAGS, will break the compile.  `tl_assert()` macro is expanded in some destructors (e.g., `Child::~Child()` from "src/unit_tests/tlXMLParser.cc"). Since function attribute `[[noreturn]]` is defined for >=C++11, better to use that instead of `throw int(0)`
@Peter-Levine
Copy link
Owner Author

Peter-Levine commented May 6, 2017

@klayoutmatthias

Thanks for pointing that out. I found a somewhat different solution here: http://stackoverflow.com/questions/39543449/how-to-use-noreturn-attribute-in-c

From the thread:

If you are stuck with pre-C++11 compilers, you can wrap up a simple macro that uses built-in compiler attributes in a hopefully portable way:

AFAIK, __attribute__((noreturn)) is a GNU C extension and is not portable.

Standards proposal with some relevant info on noreturn portability.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants