[PATCH] D80055: Diagnose union tail padding
JF Bastien via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue May 26 09:44:43 PDT 2020
jfb added a comment.
In D80055#2042630 <https://reviews.llvm.org/D80055#2042630>, @rsmith wrote:
> I'm not convinced that this is an especially useful diagnostic (much like with `-Wpadded`), but I'm also not opposed if you are aware of cases where it would be used.
I wrote it to help with issues a codebase was having adopting variable auto-init. They were surprised at what clang did, and wish they could have known. This is just one datapoint, and I agree that generally this isn't super useful.
> It seems worth pointing out that, at least in C, merely assigning to a union member results in all padding becoming unspecified (6.2.6.1/7). So the suggestion to `memset` the union to zero and then assign to a specific union member does not work.
Indeed, this isn't something I'm trying to address here but it would be useful to do so.
I was wondering if any of the tests were surprising to you, or if the behavior described was as expected? It's certainly not tractable for most users of C and C++ (which might be fine, it shouldn't be relied on).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D80055/new/
https://reviews.llvm.org/D80055
More information about the cfe-commits
mailing list