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)
 }
----------------
vitalybuka wrote:
> vitalybuka wrote:
> > 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.
> So if go trough "aggregates" then nothing is said about padding in union.
> If we go trough "list-initialization" then value initialization should be 
> applied, part of which is zero initialization. 
> If so union padding should be initialized.
> 
> 
In C++14, the list in [dcl.init.list] starts with:
If T is an aggregate, aggregate initialization is performed.

The bullet in C++17 follows only a case for copying and then a case for string 
literals.

The bullet in the C++2a CD likewise, with an additional earlier bullet that 
also becomes aggregate initialization.

It is in C++11 where an empty list gets value-initialization treatment, and the 
next bullet goes to aggregate initialization.

The inline comment was not added to an empty list case.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68115



_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to