[cfe-commits] r130453 - in /cfe/trunk: lib/CodeGen/CGExprAgg.cpp lib/CodeGen/CGExprCXX.cpp test/CodeGenCXX/value-init.cpp

Chandler Carruth chandlerc at google.com
Thu Apr 28 16:42:50 PDT 2011


On Thu, Apr 28, 2011 at 4:36 PM, Chris Lattner <clattner at apple.com> wrote:

>
> On Apr 28, 2011, at 3:57 PM, Argyrios Kyrtzidis wrote:
>
> > Author: akirtzidis
> > Date: Thu Apr 28 17:57:55 2011
> > New Revision: 130453
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=130453&view=rev
> > Log:
> > Cut down unnecessary zero'ing when value-initializing arrays of C++
> objects.
> >
> > -C++ objects with user-declared constructor don't need zero'ing.
>
> Are you sure that this is true?  Apparently the C++ standard requires that
> global variables (at least) are zero initialized and that constructors can
> take advantage of this.  This is apparently well defined:
>
> struct foo {
>  int x;
>
>  foo() {
>   ++x;
>  }
> } f;
>
> I'm pretty sure that this doesn't apply to temporaries etc, but it would be
> worth checking if you haven't already.
>

I checked. Variables of static and thread storage must be zero initialized
first as you describe. This is governed by [basic.start.init]p2 in the C++11
ISFD.

The initialization chapter provides no such pre-initialization for the other
storage classes.


>
> -Chris
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20110428/e07b5729/attachment.html>


More information about the cfe-commits mailing list