https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124924
Bug ID: 124924
Summary: Bogus "constexpr call flows off the end of the
function" error when breaking from expansion statement
Product: gcc
Version: 16.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: peter at wildp dot net
Target Milestone: ---
Test case:
```
constexpr int test(int num) {
template for (constexpr auto I : { 1, 2, 3, 4 }) {
if (num == I) {
break;
}
}
return num;
}
static_assert(test(1) == 1);
```
On godbolt (x86-64 gcc trunk) this fails to compile with the following error:
<source>:10:23: error: non-constant condition for static assertion
10 | static_assert(test(1) == 1);
| ~~~~~~~~^~~~
<source>:10:19: in 'constexpr' expansion of 'test(1)'
10 | static_assert(test(1) == 1);
| ~~~~^~~
<source>:10:19: error: 'constexpr' call flows off the end of the function