https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94558
Joseph S. Myers <jsm28 at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Resolution|--- |INVALID Status|UNCONFIRMED |RESOLVED --- Comment #1 from Joseph S. Myers <jsm28 at gcc dot gnu.org> --- This is not a bug. First, note that all expressions inside _Generic must satisfy all syntactic and compile-time constraints and must not involve any compile-time undefined behavior, just like an expression inside "if (0)"; it's simply that only one of the expressions ends up being evaluated at runtime when the _Generic expression is executed. So one of the compound literals tries to use an object of type A to initialize element b of the union, which results in the given error. Next, the error refers to initializing the field _ (i.e. .b._) with an incompatible type rather than to initializing .b with an incompatible type because the rule for initializing subaggregates and contained unions, in the absence of braces, is that an initializer with the correct structure or union type initializes the whole of a contained subaggregate or union, but otherwise the initializer goes down into nested subobjects. So when the initializer doesn't match the type of the field named by the designator, or the first field of that field (where an aggregate or union), or the first field of that, recursively, it ends up being interpreted as an initializer for the scalar at the start of that object; that is, the int at the start of .b. So the error message refers to the type int.