This is the mail archive of the 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: PATCH RFA: -Wc++-compat warning about duplicate decls

Robert Dewar wrote:
> Dave Korn wrote:
>> Robert Dewar wrote:
>>> Ian Lance Taylor wrote:
>>>> In C, it's OK to write
>>>>   int i;
>>>>   int i;
>>>> In C++, it is not.  This patch adds a -Wc++-compat warning for this
>>>> case.  This patch requires approval from the C frontend maintainers.
>>> shouldn't this in any case generate a warning in C, how can
>>> it be useful to do this, regardless of C++ compatibility.
>>   I don't understand.  These are just uninitialised commons, aren't
>> they?  Why would a C compiler warn about that?
> because it seems like fundamentally suspicious code to me, and that's
> what warnings are about. I can't see how this could ever be useful
> (a fact that is apparently recognized in the C++ standard :-))

  Well, it's truly outdated, but in k'n'r style they could come from being
declared in multiple header files (without any 'extern').  Since the more
modern standards still contain the concept of "tentative definition", I don't
think the C frontend need care about this usage.  Maybe under -Wextra or
something, but not by default IMO.


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