Created on 2025-05-12.00:00:00 last changed 1 month ago
Suggested resolution (emphasizing the prohibition):
Change in 11.5.2 [class.union.anon] paragraph 1 as follows:
... Nested types, including closure types (7.5.6.2 [expr.prim.lambda.closure]) and anonymous unions, and functions shall not be declared within an anonymous union....
(From submission #706.)
Consider:
static union { int x = [] { return 42; }(); };
According to 11.5.2 [class.union.anon] paragraph 1, this is ill-formed, because the closure type is declared as a nested type of the anonymous union (7.5.6.2 [expr.prim.lambda.closure] paragraph 3, but some implementations do not yield a diagnostic.
On the other hand, the code shown in the example is reasonable and ought to be allowed.
History | |||
---|---|---|---|
Date | User | Action | Args |
2025-07-26 20:28:50 | admin | set | messages: + msg8047 |
2025-05-12 00:00:00 | admin | create |