Replacing macro guarded throw with __libcpp_throw
Details
Diff Detail
Event Timeline
Before replacing all throw/assert to macros, let's first check if we're on the right path.
We actually have a non-macro that does this. It's called __libcpp_throw and it lives in <exception>. Please use that instead.
Sure. I'm working on it. Just got interrupted/distracted by other tasks time to time. :(
include/array | ||
---|---|---|
209 | the error message of the assert was perhaps better? | |
219 | the error message of the assert was perhaps better? | |
include/experimental/dynarray | ||
279 | the error message of the assert was perhaps better? | |
291 | ditto | |
include/map | ||
1446 | looks like extra spaces in this message (which was there in the original, I know) | |
1457 | extra spaces here too |
Generally looks OK to me.
There are similar uses in test sources as well, but those can be taken care of separately (I'm hoping to get back to the -fno-exceptions XFAILs soon).
include/exception | ||
---|---|---|
262 | something like this? #ifndef __LIBCPP_NO_EXCEPTIONS #define NORETURN_EXP __attribute__((noreturn)) #else #define NORETURN_EXP #endif inline NORETURN_EXP void libcpp_throw(_Exception const& e) { ... } | |
src/future.cpp | ||
96 | It looks ok here. The first underscore is on the same column as "__has_value" (the line above). 4 space indention | |
src/locale.cpp | ||
527 | The reason I skipeed this and two or three other similar cases is the constructor expects the function __libcpp_throw() to return a pointer. |
I just realized that this will break the following code:
try { __cxxabiv1:: __cxa_bad_cast(); } catch ( std::bad_cast &ex ) {}
because what gets thrown is a const std::bad_cast &
Yes, people should catch by value or const reference.
But that doesn't mean that they always do.
include/exception | ||
---|---|---|
262 | There's another patch out for review that adds noreturn attributes for some functions when exceptions are disabled. I suggested a macro name like _LIBCPP_NO_RETURN_WHEN_EXCEPTIONS_DISABLED for this instead of using the [[noreturn]] or __attribute__((noreturn)) . I can't find the review at the moment, but I'll turn it up. |
the error message of the assert was perhaps better?