https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113595
Bug ID: 113595
Summary: Confusing 'goto' is not a constant expression error
message in constructor at compile time
Product: gcc
Version: 14.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: hewillk at gmail dot com
Target Milestone: ---
template<int N>
struct MyArr {
constexpr MyArr(const int (&arr)[N]) {
for (int i = 0; i < N; i++)
arr_[i] = arr[i];
}
int arr_[N];
};
constexpr int arr[10] = {};
constexpr MyArr<10> my_arr(arr);
https://godbolt.org/z/978rTjqGP
---------------
GCC correctly (I think) rejects the above code, but the error message is a bit
confusing:
<source>:4:5: error: 'goto' is not a constant expression
4 | for (int i = 0; i < N; i++)
| ^~~
since there is no 'goto' in the code.