Index: clang/lib/CodeGen/CGExprAgg.cpp =================================================================== --- clang/lib/CodeGen/CGExprAgg.cpp +++ clang/lib/CodeGen/CGExprAgg.cpp @@ -1685,7 +1685,7 @@ // Make sure that it's really an empty and not a failure of // semantic analysis. for (const auto *Field : record->fields()) - assert(Field->isUnnamedBitfield() && "Only unnamed bitfields allowed"); + assert((Field->isUnnamedBitfield() || Field->isAnonymousStructOrUnion()) && "Only unnamed bitfields or ananymous class allowed"); #endif return; } Index: clang/test/SemaCXX/anonymous-struct.cpp =================================================================== --- clang/test/SemaCXX/anonymous-struct.cpp +++ clang/test/SemaCXX/anonymous-struct.cpp @@ -189,3 +189,20 @@ } } A; // expected-note {{given name 'A' for linkage purposes by this typedef}} } + +#if __cplusplus > 201103L +namespace GH58800 { +struct A { + union { + struct { + float red = 0.0f; + }; + }; +}; + +A GetA() { + A result{}; + return result; +} +} +#endif