https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120503
Bug ID: 120503
Summary: P2115R0 (merging unnamed enumerations) is not fully
implemented
Product: gcc
Version: 15.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: gulackeg at gmail dot com
Target Milestone: ---
On the webpage "C++ Standards Support in GCC"[1], P2115R0[2] is marked as
available since GCC 11. However, this does not appear to reflect the current
state of implementation. The following test code[3], derived from the paper,
illustrates the issue:
// Frob.cpp
template <auto V> int Frob() { return int(V); }
enum { A = 195'936'478 };
template int Frob<A>();
// main.cpp
enum { Noise };
template <auto V> int Frob() { return int(V); }
enum { A = 195'936'478 };
extern template int Frob<A>();
int main() { Frob<A>(); }
Linking the above code results in the following error:
main.cpp:7:(.text+0x5): undefined reference to
`_Z4FrobITnDaL8._anon_1195936478EEiv'
According to the paper, this code should be well-formed, as the mangled name
for the type of `A` is expected to remain consistent across translation units
(by using the name of the first enumerator—`A`).
[1] https://gcc.gnu.org/projects/cxx-status.html#cxx20
[2] https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2020/p2115r0.html
[3] https://godbolt.org/z/coxPKrGva