[PATCH] D147626: [clang] Reject flexible array member in a union in C++
Eli Friedman via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed May 3 12:35:09 PDT 2023
efriedma added a comment.
In D147626#4316212 <https://reviews.llvm.org/D147626#4316212>, @aaron.ballman wrote:
> In D147626#4316190 <https://reviews.llvm.org/D147626#4316190>, @efriedma wrote:
>
>>> If there's not indications of this being disruptive on non-MSVC-compatible targets, then we may still be able to get away with rejecting the extension there.
>>
>> If we need to have the codepath anyway, there isn't much harm in allowing it on all targets, I think. There's really only one possible interpretation for the construct.
>
> You would think, except the GCC extension differs based on C vs C++: https://godbolt.org/z/E14Yz37To as does the extension in Clang, but differently than GCC: https://godbolt.org/z/zYznaYPf5 and so we'd also have to dig into solving that if we wanted to keep GCC compatibility behavior.
I don't see any unions there? Declaring a flexible array is separate from flexible array initialization.
Actually, despite my saying the interpretation for unions is "obvious", it's actually a little more weird than I thought: `union x { short x[]; }; static_assert(sizeof(x)==2);` compiles with msvc.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D147626/new/
https://reviews.llvm.org/D147626
More information about the cfe-commits
mailing list