This is the mail archive of the gcc-patches@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 PATCH] diagnose built-in declarations without prototype (PR 83656)


On 06/26/2018 08:57 PM, Martin Sebor wrote:
> With the exception of built-ins with the ellipsis (like sprintf),
> GCC silently accepts declarations of built-in functions without
> prototypes as well as calls to such functions with any numbers
> or types of arguments, compatible or otherwise.  Calls with
> arguments whose number and types match exactly those of
> the built-in are considered by the middle-end for optimization.
> Other calls (compatible or not, irrespective of whether their
> number matches the number expected by the function) are then
> made to the library functions.
> 
> Attached is a small fix to -Wbuiltin-declaration-mismatch to
> have it diagnose built-in declarations without a prototype.
> The warning is enabled by default so it causes a fair number
> of tests to fail because of declarations like 'void abort();'
> The breakdown of the built-ins behind the test failures is
> below.
> 
> Before I take the time to clean up the test suite let me post
> what I have in case going this route is not acceptable.  As
> an alternative, I could try to avoid some of these warnings,
> e.g., by diagnosing incompatible calls instead but I think
> it's even less worthwhile for built-ins than trying to do
> it for ordinary functions with -Wstrict-prototypes.  There
> is, in my view, no justification today for standard functions
> to be declared without a prototype.  (I could also make
> the warning depend on language mode and -Wpedantic if that
> were more preferable.)
> 
> Martin
> 
> About 115 tests fail due to incompatible declarations of
> the built-in functions below (the number shows the number
> of warnings for each functions):
> 
> 428   abort
>  58   exit
>  36   memcpy
>  17   memmove
>  15   realloc
>  14   cabs
>   5   strncpy
>   4   strcmp
>   3   alloca
>   2   rindex
>   1   aligned_alloc
I'm supportive of this change.  Though I'm more worried about the
affects on the distros than I am on the testsuite (which I expected to
be in worse shape WRT this issue than your analysis indicates).

Unfortunately I don't have the tester set up to do distro style testing
yet.  So I can't just throw your patch in and see what is spit out.  But
even so, I still think this is the right thing to do.

Jeff


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