noexcept doesn’t prevent any throws at compile-time, it basically just wraps the function in a `catch(...)` block that will call std::terminate, like a failed assert. IMHO it is a stupid feature for this very confusion.
This just feels important to point out because this feature is 15 years old and still commonly misunderstood, and each time people are wanting the same thing (actual compile-time prevention of `throw`) which it is not.
Edit: OK I finally just went and tried it on godbolt.org. C++17 GCC, Clang, and MSVC all give 1 warning on this code for `bar` and that's all.
void canthrow() {
throw 42;
}
void foo() noexcept {
canthrow();
}
void bar() noexcept {
throw 42;
}https://godbolt.org/z/rjPfYjnzf
https://godbolt.org/z/14ocshsE5
I filed bugs against both GCC and LLVM requesting warnings: