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: Building GCC with -Wmissing-declarations and addressing its warnings


On Thu, Feb 20, 2014 at 2:16 AM, Jonathan Wakely <jwakely.gcc@gmail.com> wrote:
> On 13 February 2014 20:47, Patrick Palka wrote:
>> On a related note, would a patch to officially enable
>> -Wmissing-declarations in the build process be well regarded?
>
> What would be the advantage?

A missing declaration for an extern function definition likely means
that the function should be marked static instead, so enabling the
flag would help detect whether a function should otherwise be given
static linkage.  Isn't this especially important in libstdc++, where
accidentally exposing an internal symbol in the library's ABI means
having to keep the symbol around until the next ABI bump?

>
>>  Since
>> -Wmissing-prototypes is currently enabled, I assume it is the
>> intention of the GCC devs to address these warnings, and that during
>> the transition from a C to C++ bootstrap compiler a small oversight
>> was made (that -Wmissing-prototypes is a no-op against C++ source
>> files).
>
> The additional safety provided by -Wmissing-prototypes is already
> guaranteed for C++.
>
> In C a missing prototype causes the compiler to guess, probably
> incorrectly, how to call the function.
>
> In C++ a function cannot be called without a previous declaration and
> the linker will notice if you declare a function with one signature
> and define it differently.

Good point..  -Wmissing-declarations does not provide additional
safety to C++.  Really the only benefit to the flag is the static
thing mentioned above.


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