Open seanbaxter opened 2 years ago
Can you explain where you find this reference in the source so we know who to direct this issue to.
I don't know anything about the clang source. It simply appears not to be conformant in this instance
I'm not an expert anymore but I agree that strict reading of the C++ standard does seem to imply that an empty struct or union type is not a literal type. At the same time, all compilers on Godbolt I tried (GCC, ICC, and Visual C++) fail the assertion the same way Clang does, and note 4 at the end of paragraph 10 suggests the intent might actually be to treat such types as literal:
[ Note: A literal type is one for which it might be possible to create an object within a constant expression. It is not a guarantee that it is possible to create such an object, nor is it a guarantee that any object of that type will usable in a constant expression. — end note]
@llvm/issue-subscribers-clang-frontend
If I am reading the proposed resolution to DR2598 I believe it proposes to allow empty unions to be literal type:
is an aggregate type (9.4.2 [dcl.init.aggr]) for which that type (if it is a union) or each of its anonymous union members (otherwise) either has at least one variant member of non-volatile literal type or has no variant members, or
CC @zygoloid
https://eel.is/c++draft/basic#types.general-10.5.3