I am not a standardista, but this doesn't seem right to me. The target 
constructor finishes before the delegating constructor runs, and presumably the 
target constructor has to be able to initialize the entire object by itself. I 
don't see anything in the standard that says 'x' is zero-initialized by the 
default constructor on its own, the default constructor as a target, or the 
delegating constructor.

As I see it, if there was a member of another class that had an X member, 'X()' 
wouldn't zero-initialize 'x'. The standard [class.base.init p7] seems to imply 
that delegating initialization works the same way as member initialization.

Where is the zero initialization coming from in this case anyway?

Jordy


On May 19, 2012, at 20:46, Eli Friedman wrote:

> Author: efriedma
> Date: Sat May 19 19:46:05 2012
> New Revision: 157138
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=157138&view=rev
> Log:
> Zap a bogus assert for delegating constructors.  PR12890, part 2.
> 
> I'm pretty sure we are in fact doing the right thing here, but someone who 
> knows the standard better should double-check that we are in fact supposed to 
> zero out the member in the given testcase.
> 
> 
> Modified:
>    cfe/trunk/lib/CodeGen/CGExprCXX.cpp
>    cfe/trunk/test/CodeGenCXX/cxx0x-delegating-ctors.cpp
> 
> Modified: cfe/trunk/lib/CodeGen/CGExprCXX.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprCXX.cpp?rev=157138&r1=157137&r2=157138&view=diff
> ==============================================================================
> --- cfe/trunk/lib/CodeGen/CGExprCXX.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGExprCXX.cpp Sat May 19 19:46:05 2012
> @@ -409,7 +409,6 @@
>   if (E->requiresZeroInitialization() && !Dest.isZeroed()) {
>     switch (E->getConstructionKind()) {
>     case CXXConstructExpr::CK_Delegating:
> -      assert(0 && "Delegating constructor should not need zeroing");
>     case CXXConstructExpr::CK_Complete:
>       EmitNullInitialization(Dest.getAddr(), E->getType());
>       break;
> 
> Modified: cfe/trunk/test/CodeGenCXX/cxx0x-delegating-ctors.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/cxx0x-delegating-ctors.cpp?rev=157138&r1=157137&r2=157138&view=diff
> ==============================================================================
> --- cfe/trunk/test/CodeGenCXX/cxx0x-delegating-ctors.cpp (original)
> +++ cfe/trunk/test/CodeGenCXX/cxx0x-delegating-ctors.cpp Sat May 19 19:46:05 
> 2012
> @@ -54,3 +54,14 @@
> delegator::delegator(int)
>   : delegator()
> {}
> +
> +namespace PR12890 {
> +  class X {
> +    int x;
> +    X() = default;
> +    X(int);
> +  };
> +  X::X(int) : X() {}
> +}
> +// CHECK: define {{.*}} @_ZN7PR128901XC1Ei(%"class.PR12890::X"* %this, i32)
> +// CHECK: call void @llvm.memset.p0i8.i64(i8* {{.*}}, i8 0, i64 4, i32 4, i1 
> false)
> 
> 
> _______________________________________________
> cfe-commits mailing list
> [email protected]
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to