[cfe-commits] r91548 - in /cfe/trunk: include/clang/AST/ExprCXX.h lib/AST/ExprCXX.cpp lib/CodeGen/CGCXX.cpp lib/CodeGen/CGExprAgg.cpp lib/Frontend/PCHReaderStmt.cpp lib/Frontend/PCHWriterStmt.cpp lib/Sema/Sema.h lib/Sema/SemaDeclCXX.cpp lib/Sema/SemaInit.cpp test/CodeGenCXX/value-init.cpp test/SemaCXX/dcl_init_aggr.cpp

Chris Lattner clattner at apple.com
Thu Dec 17 09:52:37 PST 2009


On Dec 17, 2009, at 9:41 AM, Douglas Gregor wrote:
>> Value-initialized != unconstructed. Value-initialized is the formal name
>> for what is done to objects without user-defined default constructor
>> initialized with '()' in new-expressions and initializer lists, as well as
>> objects in an array with initializer of insufficient size. It's also what
>> will happen to objects initialized with the uniform initializer '{}' in
>> C++0x.
> 
> Right. You don't get value-initialization (with the zero-fill) for something like
> 
>  void f() {
>    X x;
>  }
> 
> but you would get it for something like:
> 
>  struct Y {
>    X x;
>    Y() : x() { }
>  };
> 
> The motivation for the change to zero-initialize first then call the default constructor is that a value-initialized object should be identical to a global variable of the same type, as noted here:

Ok, that's still unfortunate, but we'll see if it actually matters in practice.

-Chris



More information about the cfe-commits mailing list