[PATCH] D68115: Zero initialize padding in unions

Hubert Tong via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Sep 26 20:39:42 PDT 2019


hubert.reinterpretcast 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)
 }
----------------
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.


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