https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124417
--- Comment #6 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Jakub Jelinek <[email protected]>: https://gcc.gnu.org/g:f233f787c2cef68282976cc6a507eba4e62827cb commit r16-7996-gf233f787c2cef68282976cc6a507eba4e62827cb Author: Jakub Jelinek <[email protected]> Date: Wed Mar 11 07:54:36 2026 +0100 c++: Emit error if not quiet and set *non_constant_p for -fno-exceptions metafn error cases [PR124417] For -fno-exceptions, we reject throw statements in the source, and a lot of code in the header has #ifdef __cpp_exceptions guarded stuff and the FE for !flag_exceptions doesn't emit some parts of the IL needed for exceptions. For the errors in metafns, we had just a todo to handle it in the source but no actual implementation, so we allowed throwing an exception and sometimes it worked to some extent and sometimes it didn't. The following patch fixes it by not throwing an exception if user asked for -fno-exceptions - instead we just emit an error including the planned what () (unless ctx->quiet) and make the evaluation non-constant. 2026-03-11 Jakub Jelinek <[email protected]> PR c++/124417 * reflect.cc (get_meta_exception_object): Add CTX argument. For !flag_exceptions emit error unless ctx->quiet, set *non_constant_p to true and return NULL_TREE instead of throwing an exception. (throw_exception): Adjust get_meta_exception_object caller. * g++.dg/reflect/no-exceptions1.C: New test. Reviewed-by: Jason Merrill <[email protected]>
