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

Richard Smith richard at metafoo.co.uk
Fri Dec 28 05:38:26 PST 2012


On Fri, Dec 28, 2012 at 3:05 AM, Sebastian Redl
<sebastian.redl at getdesigned.at> wrote:
>
> 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.

Sadly no, this doesn't disable gcc's warning, but I generally agree
that it's a better idiom.



More information about the cfe-commits mailing list