https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126354
--- Comment #2 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:571aae1dc596ec58bca11534800a857109dce498 commit r17-2664-g571aae1dc596ec58bca11534800a857109dce498 Author: Jakub Jelinek <[email protected]> Date: Thu Jul 23 15:42:10 2026 +0200 c++: Diagnose return from [[noreturn]] function during constant evaluation [PR126354] This PR complains about g++ not diagnosing return from [[noreturn]] function (which is UB) during constant evaluation. This patch diagnoses that. I haven't included the [[noreturn]] function name in the diagnostics as it is printed in the context: /home/jakub/src/gcc/gcc/testsuite/g++.dg/cpp1y/pr126354.C:18:24: in 'constexpr' expansion of 'bar()' /home/jakub/src/gcc/gcc/testsuite/g++.dg/cpp1y/pr126354.C:15:7: in 'constexpr' expansion of 'foo(false)' /home/jakub/src/gcc/gcc/testsuite/g++.dg/cpp1y/pr126354.C:15:7: error: '[[noreturn]]' call returns But if you think it is better to emit error ("%<[[noreturn]]%> %qD call returns", fun); instead, I can certainly do that. 2026-07-23 Jakub Jelinek <[email protected]> PR c++/126354 * constexpr.cc (cxx_eval_call_expression): Diagnose return from [[noreturn]] function. * g++.dg/cpp1y/pr126354.C: New test. * g++.dg/cpp26/pr126354.C: New test. Reviewed-by: Jason Merrill <[email protected]>
