[PATCH] D147626: [clang] Reject flexible array member in a union in C++
Mariya Podchishchaeva via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri May 12 02:45:39 PDT 2023
Fznamznon added a comment.
> Well that's... a bit shorter... than I would have expected that union to be. (I'm not apologizing for the pun.)
In clang `union x { short x[]; }; static_assert(sizeof(x)==2);` evaluates to '0 == 2'. That is even shorter, I guess? This is also the reason why
union A {char x[]; };
A a = {0};
keeps crashing even after my fix. It feels like we're not even close to be compatible with msvc. I would probably prefer submitting the original fix and submitting an issue to clean up the mess with this extension. At least this way it won't crash in C after issuing an error, like this https://godbolt.org/z/5oxYTq5fq
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