This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: RFC: PR 25137: moving -Wmissing-braces to -Wextra?


On Tue, Nov 17, 2009 at 4:05 PM, Ian Lance Taylor <iant@google.com> wrote:
> Paolo Carlini <paolo.carlini@oracle.com> writes:
>
>> I'm trying to resolve one way or another this PR, which I have assigned
>> to myself a long time ago... The issue essentially is very simple. This
>> kind of code:
>>
>> ? ? struct S { int s[3]; };
>> ? ? struct S s1 = { 1, 1, 1 };
>>
>> triggers a warning with -Wall about missing braces around initializer,
>> which some people consider a bit overzealous, in particular in
>> relationship with std::array (std::tr1::array).
>>
>> Today, I was comparing GCC to ICC and SunStudio and noticed that, please
>> correct me if I'm wrong about the details:
>>
>> ? ? - ICC: lacks completely an equivalent of -Wmissing-braces, never warns.
>> ? ? - SunStudio: only warns with +w2, doesn't warn with +w.
>>
>> Therefore, my idea to resolve 25137 and make progress in this area would
>> be moving -Wmissing-braces from -Wall to -Wextra: the corresponding
>> patch, as expected, is trivial, and it would be for me only matter to
>> tweak the testsuites a bit (A refinement of that proposal would be doing
>> the change only for the C++ front-end)
>
> The point of -Wmissing-braces is to warn if you if you are not
> initializing the fields you think you are. ?Given that, I tend to feel
> that -Wmissing-braces is doing the right thing, and I tend to feel
> that it should be in -Wall.
>
> I could see a counter-argument for special cases like the above, but
> then we have to start enumerating special cases.
>
> I don't really understand how this interacts with std::tr1:array,
> though.

That makes the use of std::array<> very annoying.  From that perspective
I believe the warning *in this specific case*  is not just overzealous, but
downright harmful.

-- Gaby



>
> Ian
>


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]