https://gcc.gnu.org/bugzilla/show_bug.cgi?id=129246
Bug ID: 129246
Summary: [14/15/16/17 Regression] ICE or nondeterministic
undefined references with multiple levels of consteval
escalation
Product: gcc
Version: 16.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: rs2740 at gmail dot com
Target Milestone: ---
Repro:
struct S {
consteval S(char const* p) : p(p) {}
char const* p;
};
template <class T>
struct Storage {
T data;
template <class A>
constexpr Storage(A&& a) : data(static_cast<A&&>(a)) {}
};
template <class T>
struct R {
Storage<T> e;
template <class A>
constexpr R(A&& a) : e(static_cast<A&&>(a)) {
}
};
R<S> f1() { return {"x"}; }
R<S> f2() { return {"xx"}; }
R<S> f3() { return {"xxx"}; }
R<S> f4() { return {"xxxx"}; }
R<S> f5() { return {"xxxxx"}; }
R<S> f6() { return {"xxxxxx"}; }
R<S> f7() { return {"xxxxxxx"}; }
R<S> f8() { return {"xxxxxxxx"}; }
R<S> f9() { return {"xxxxxxxxx"}; }
R<S> f10() { return {"xxxxxxxxxx"}; }
R<S> f11() { return {"xxxxxxxxxxx"}; }
R<S> f12() { return {"xxxxxxxxxxxx"}; }
R<S> f13() { return {"xxxxxxxxxxxxx"}; }
R<S> f14() { return {"xxxxxxxxxxxxxx"}; }
R<S> f15() { return {"xxxxxxxxxxxxxxx"}; }
R<S> f16() { return {"xxxxxxxxxxxxxxxx"}; }
R<S> f17() { return {"xxxxxxxxxxxxxxxxx"}; }
R<S> f18() { return {"xxxxxxxxxxxxxxxxxx"}; }
R<S> f19() { return {"xxxxxxxxxxxxxxxxxxx"}; }
R<S> f20() { return {"xxxxxxxxxxxxxxxxxxxx"}; }
R<S> f21() { return {"xxxxxxxxxxxxxxxxxxxxx"}; }
R<S> f22() { return {"xxxxxxxxxxxxxxxxxxxxxx"}; }
R<S> f23() { return {"xxxxxxxxxxxxxxxxxxxxxxx"}; }
R<S> f24() { return {"xxxxxxxxxxxxxxxxxxxxxxxx"}; }
R<S> f25() { return {"xxxxxxxxxxxxxxxxxxxxxxxxx"}; }
R<S> f26() { return {"xxxxxxxxxxxxxxxxxxxxxxxxxx"}; }
R<S> f27() { return {"xxxxxxxxxxxxxxxxxxxxxxxxxxx"}; }
R<S> f28() { return {"xxxxxxxxxxxxxxxxxxxxxxxxxxxx"}; }
R<S> f29() { return {"xxxxxxxxxxxxxxxxxxxxxxxxxxxxx"}; }
R<S> f30() { return {"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"}; }
R<S> f31() { return {"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"}; }
R<S> f32() { return {"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"}; }
R<S> f33() { return {"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"}; }
R<S> f34() { return {"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"}; }
R<S> f35() { return {"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"}; }
R<S> f36() { return {"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"}; }
R<S> f37() { return {"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"}; }
R<S> f38() { return {"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"}; }
R<S> f39() { return {"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"}; }
R<S> f40() { return {"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"}; }
int main() {}
With gcc 16.2 -std=c++20/23/26 -O0, this emits a good number of undefined
references to Storage's constructor, as does gcc 15.3 and gcc 14.3/14.4. See
examples: https://compiler-explorer.com/z/6bcG3sb54.
Trunk appears to ICE in gimplify_expr. .
GCC 14.2 behaves as expected, as do Clang 22/23. If I change either R or
Storage's constructor to consteval everything also works, so one level of
escalation appears to be ok.
The exact number of undefined references emitted appears to change depending on
the compiler version and standard revision. An LLM I used to reduce this claims
that it can also vary based on other seemingly unrelated factors such as the
number of unrelated macros defined on the command line, but I have not
personally verified that claim.