[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] avoid warnings about initialization of automatic aggregates
From: |
Jim Meyering |
Subject: |
Re: [PATCH] avoid warnings about initialization of automatic aggregates |
Date: |
Tue, 02 Dec 2008 10:55:04 +0100 |
Pádraig Brady <address@hidden> wrote:
> Jim Meyering wrote:
>> Pádraig Brady <address@hidden> wrote:
>>> Jim Meyering wrote:
>>>> Finally getting serious about avoiding warnings,
>>>> I've just eliminated this batch:
>>>>
>>>> >From c58b5daa337b16416be50adfeb3e99e3c009c891 Mon Sep 17 00:00:00 2001
>>>> From: Jim Meyering <address@hidden>
>>>> Date: Sun, 30 Nov 2008 22:37:42 +0100
>>>> Subject: [PATCH] avoid warnings about initialization of automatic
>>>> aggregates
>>>>
>>>> * src/system.h (DZA_CONCAT0, DZA_CONCAT): New macros.
>>>> (DECLARE_ZEROED_AGGREGATE): New macro.
>>> Some notes on this issue:
>>> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36750
>>> So the warning can be suppressed in gcc with
>>> -Wno-missing-field-initializers
>>
>> Thanks. However, I prefer not to use this -Wno... option, because
>> it could later hide some legitimate warnings in the affected files.
>
> Absolutely.
>
> Thinking a bit more about your patch, I'm not sure about the use of
> static variables as this is a logically different thing. I.E. the static
> variables will only be initialised at program start, whereas 'type var =
> {0,}' would be initialised each time the scope is entered.
> For e.g. I think quote_name() in ls.c will now behave differently?
Only the temporary is static.
The original code (that evokes a warning) is like this:
mbstate_t mbstate = { 0, };
Using DECLARE_ZEROED_AGGREGATE, it's like this (modulo formatting onto
two lines and the approximate line number)
static mbstate_t s0_3724;
mbstate_t mbstate = s0_3724;
I considered using memset, but preferred the above.
So I think we're ok.