<div style="font-family: arial, helvetica, sans-serif; font-size: 10pt"><div dir="ltr"><div class="gmail_default" style>On Thu, Dec 27, 2012 at 4:22 PM, Joerg Sonnenberger <span dir="ltr"><<a href="mailto:joerg@britannica.bec.de" target="_blank" class="cremed">joerg@britannica.bec.de</a>></span> wrote:<br>
</div><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On Thu, Dec 27, 2012 at 04:05:37PM -0800, Chandler Carruth wrote:<br>

> On Thu, Dec 27, 2012 at 4:01 PM, Joerg Sonnenberger <<a href="mailto:joerg@britannica.bec.de" class="cremed">joerg@britannica.bec.de</a><br>
> > wrote:<br>
><br>
> > On Thu, Dec 27, 2012 at 01:49:06PM -0500, Howard Hinnant wrote:<br>
> > > > @@ -4583,7 +4584,7 @@<br>
> > > >  string<br>
> > > >  __time_get_storage<char>::__analyze(char fmt, const ctype<char>& ct)<br>
> > > >  {<br>
> > > > -    tm t = {0};<br>
> > > > +    tm t = {0,0,0,0,0,0,0,0,0,0,0};<br>
> > > >      t.tm_sec = 59;<br>
> > > >      t.tm_min = 55;<br>
> > > >      t.tm_hour = 23;<br>
> > > > @@ -4729,7 +4730,7 @@<br>
> > > >  wstring<br>
> > > >  __time_get_storage<wchar_t>::__analyze(char fmt, const<br>
> > ctype<wchar_t>& ct)<br>
> > > >  {<br>
> > > > -    tm t = {0};<br>
> > > > +    tm t = {0,0,0,0,0,0,0,0,0,0,0};<br>
> > > >      t.tm_sec = 59;<br>
> > > >      t.tm_min = 55;<br>
> > > >      t.tm_hour = 23;<br>
> > ><br>
> > > Rejected.  tm contains *at least* 9 int data members.  The portable and<br>
> > > concise way to zero initialize this struct is with the single {0}.<br>
> ><br>
> > What about using memset as alternative?<br>
><br>
><br>
> Why? The compiler warning from GCC is simply wrong. The other members are<br>
> in fact initialized. I see no reason to use a more verbose construct which<br>
> requires a declaration of an external function merely to avoid a patently<br>
> incorrect warning.<br>
<br>
</div></div>The compiler warning from GCC is for the (common) case that a field is<br>
added later and so the initializer depends only on the default value of<br>
the field. That warning is helpful for plain C, but not so much for C++<br>
data structures, where constructures serve the purpose of preserving API<br>
compatibility.</blockquote><div><br></div><div style>There are common patterns that are pretty well established in both C and C++, that should not trigger such a warning. I think '= {0}' is one such pattern...</div>
<div> </div></div></div></div></div>