https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93210
Jakub Jelinek <jakub at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jakub at gcc dot gnu.org --- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> --- >From C++ POV, Should when passed by reference to the operator== is odr-used and therefore the static data member definition is required (unless C++17 or newer where it is inline variable and the definition is already in the class definition). The rest is just a matter of optimization, where we for yet to be determined reason punt in the anonymous struct in union case, as can be seen on C testcase (but likewise with C++): union U { int a[2]; long long b; }; static const union U u = { .a = { 1, 2 } }; union V { struct { int a, b; }; long long c; }; static const union V v = { { 1, 2 } }; void qux (const union U *, const union V *); long long foo (void) { if (sizeof (long long) == 2 * sizeof (int)) return u.b; else return -1; } long long bar (void) { if (sizeof (long long) == 2 * sizeof (int)) return v.c; else return -1; } void baz (void) { qux (&u, &v); }