On Thu, Apr 28, 2011 at 4:36 PM, Chris Lattner <[email protected]> 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
> [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