[cfe-commits] [PATCH] [libcxx] cleanup a few compile warnings emitted by GCC

Sebastian Redl sebastian.redl at getdesigned.at
Fri Dec 28 03:05:33 PST 2012


On 27.12.2012, at 19:49, Howard Hinnant wrote:

> On Dec 25, 2012, at 11:54 AM, Saleem Abdulrasool <compnerd at compnerd.org> wrote:
> 
>> @@ -4583,7 +4584,7 @@
>> string
>> __time_get_storage<char>::__analyze(char fmt, const ctype<char>& ct)
>> {
>> -    tm t = {0};
>> +    tm t = {0,0,0,0,0,0,0,0,0,0,0};
>>     t.tm_sec = 59;
>>     t.tm_min = 55;
>>     t.tm_hour = 23;
>> @@ -4729,7 +4730,7 @@
>> wstring
>> __time_get_storage<wchar_t>::__analyze(char fmt, const ctype<wchar_t>& ct)
>> {
>> -    tm t = {0};
>> +    tm t = {0,0,0,0,0,0,0,0,0,0,0};
>>     t.tm_sec = 59;
>>     t.tm_min = 55;
>>     t.tm_hour = 23;
> 
> Rejected.  tm contains *at least* 9 int data members.  The portable and concise way to zero initialize this struct is with the single {0}.

For C++, isn't {} a better initializer? Unlike in C, in C++ (even 98) an empty initializer list is valid, and it means the right thing. It could also be that GCC doesn't emit a warning in this case.

Sebastian
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20121228/a3aadff6/attachment.html>


More information about the cfe-commits mailing list