https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118053
Bug ID: 118053
Summary: [14/15 Regression] Only -Ox -std=c++2x internal
compiler error: in cxx_eval_indirect_ref, at
cp/constexpr.cc:5954
Product: gcc
Version: 14.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: yjwoo14 at gmail dot com
Target Milestone: ---
Reproducer: https://godbolt.org/z/3WMo4PPMP
Only errors with -Ox option and -std=c++20 (or c++23) on gcc-14 or gcc-15.
```cpp
#include <iostream>
#include <vector>
template <typename Funct> void run(Funct funct = Funct()) { funct(1); }
std::vector<int> runner() {
try {
std::vector<int> vec = {1};
run([&](const auto &num) { vec.back() = num; });
return vec;
} catch (...) {
}
return {};
}
int main() {
auto vec = runner();
std::cout << vec.back() << std::endl;
}
```