https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124181
Bug ID: 124181
Summary: constexpr function with null statement throws compile
error in C++11, but should be ok by specification
Product: gcc
Version: 15.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: giovanni.gaio at proton dot me
Target Milestone: ---
Created attachment 63732
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=63732&action=edit
Minimal non-compiling exmple
When trying to compile a `constexpr` function that contains null statements
(useful to avoid warnings about unused parameters) and specifying the C++11
stabdard, compilation fails with the following error:
`body of 'constexpr' function 'constexpr int foo(int, int)' not a
return-statement`
See the minimal example here: https://godbolt.org/z/d96r9eME7
The C++11 specification explicitly allows null statements to be part of the
body of a constexpr function, so this should be allowed. (see for example
https://en.cppreference.com/w/cpp/language/constexpr.html )