[PATCH] D26458: Protect nested-exceptions tests under no-exceptions
Asiri Rathnayake via cfe-commits
cfe-commits at lists.llvm.org
Sat Nov 19 06:15:58 PST 2016
rmaprath added a comment.
In https://reviews.llvm.org/D26458#594069, @EricWF wrote:
> There are cases where it is useful to be able to name `std::nested_exception` while exceptions are disabled.
I was thinking about the opposite. That is, we might want to consider disabling the `<exception>` header altogether when compiling with `-fno-exceptions`. My particular use case is to do with futures:
void make_hello(std::promise<std::string> &p, bool set_exception) {
if (set_exception)
p.set_exception(std::make_exception_ptr(
std::runtime_error {"No hellos left."}));
else
p.set_value("Hello world!");
}
This will compile fine with `-fno-exceptions` and when the client thread attempts to read from the promise, whole program would crash. May be they deserve it, but I feel like it's something we can help with; if we disable the `<exception>` header, this code wouldn't compile under `-fno-exceptions`.
In what cases do we need to allow various exception types under `-fno-exceptions`?
Cheers,
/ Asiri
Repository:
rL LLVM
https://reviews.llvm.org/D26458
More information about the cfe-commits
mailing list