https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118263
--- Comment #6 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Richard Yao from comment #0)
> WaitForSingleObjectEx() is a C ABI function and thus invoking a C++
> exception in it triggers undefined behavior.
No it doesn't.
The compiler has no way to know if something is "a C ABI function". Being
declared extern "C" does not make it a "C ABI function" and certainly does not
mean it can't throw (or handle) exceptions.
extern "C" void f();
extern "C" void g();
int main() {
g();
}
// Possibly in another translation unit:
extern "C" void f() { throw 1; }
extern "C" void g() { try { f(); } catch (int) { } }
> The compiler should issue a
> warning when passing a function pointer not marked noexcept to a C ABI
> function, but does not:
>
> https://godbolt.org/z/14ocshsE5
What is a "C ABI function"?
The linked code says "C API function that is implicitly noexcept" but that's
just incorrect. "C" language linkage does not imply noexcept.
That example should not produce a warning, at least not for -Wall
> Similarly, the compiler should warn about passing a function pointer to a
> function not marked noexcept to a function marked noexcept, but does not:
>
> https://godbolt.org/z/rjPfYjnzf
Not all functions that can't throw are noexcept. Not all functions that are
noexcept(false) will actually throw for a given set of arguments.
Implicit conversions from void(*)() noexcept to void (*)() are supported by
design, and are not necessarily a problem.
I think this bug report is INVALID, unless the suggestion for when to warn is
greatly improved.