[PATCH] D68115: Zero initialize padding in unions

Vitaly Buka via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Sep 27 15:40:14 PDT 2019


vitalybuka marked an inline comment as done.
vitalybuka added inline comments.


================
Comment at: clang/test/CodeGen/init.c:197
   // CHECK-LABEL: @nonzeroPaddedUnionMemset(
-  // CHECK-NOT: store
-  // CHECK-NOT: memcpy
-  // CHECK: call void @llvm.memset.p0i8.i32(i8* {{.*}}, i8 -16, i32 36, i1 false)
+  // CHECK: call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 {{.*}}, i8* align 4 {{.*}} [[INIT_PADDEDUNION]], {{.*}}, i32 36, i1 false)
 }
----------------
hubert.reinterpretcast wrote:
> This is C++ aggregate initialization and not value-initialization. The wording you quoted from the C++ standard is for zero-initialization, which might be part of value initialization, but you have not shown that aggregate initialization of a union involves zero-initialization of that union.
reading this more I don't see any evidence that either C++ or C requires padding initialization.
Reading this I expect that all function here should be equivalent https://godbolt.org/z/1O_9-e
But they are not. Clang and GCC initialized padding after the first member.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D68115/new/

https://reviews.llvm.org/D68115





More information about the cfe-commits mailing list