[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

Sebastian Redl sebastian.redl at getdesigned.at
Thu Dec 17 01:37:38 PST 2009


On Wed, 16 Dec 2009 16:21:19 -0800, Chris Lattner <clattner at apple.com>
wrote:
> On Dec 16, 2009, at 10:50 AM, Douglas Gregor wrote:
> 
>> Author: dgregor
>> Date: Wed Dec 16 12:50:27 2009
>> New Revision: 91548
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=91548&view=rev
>> Log:
>> When value-initializing a class with no user-defined constructors but
>> with a non-trivial default constructor, zero-initialize the storage
>> and then call the default constructor. Fixes PR5800.
> 
> Is this really required?  My understanding was that the only case in C+ 
> +'98 when an unconstructed object is guaranteed to zero filled is in  
> the global variable case.  Is this true in general, and if not, why  
> pay the performance cost to do the zero fill?

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.

Sebastian




More information about the cfe-commits mailing list