[PATCH] D80055: Diagnose union tail padding

Richard Smith - zygoloid via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue May 26 15:17:47 PDT 2020


rsmith added a comment.

In D80055#2055151 <https://reviews.llvm.org/D80055#2055151>, @jfb wrote:

> I was wondering if any of the tests were surprising to you, or if the behavior described was as expected?


I've highlighted one case where the test expectation doesn't match the standard rules.



================
Comment at: clang/test/CodeGen/union-tail-padding.c:42
+#elif __cplusplus < 201703
+Front front6 = Front(); // expected-warning {{Initializing union 'Front' field 'i' only initializes the first 4 of 8 bytes, leaving the remaining 4 bytes undefined}}
+Front front7 = Front{}; // expected-warning {{Initializing union 'Front' field 'i' only initializes the first 4 of 8 bytes, leaving the remaining 4 bytes undefined}}
----------------
This warning appears to be incorrect. Value-initialization of a union with a trivial default constructor performs zero-initialization, which does zero out padding bits.


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