On 6/26/18, Martin Sebor <mse...@gmail.com> 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
>

Could you do something to differentiate it a bit more from the
-Wshadow warning that is also touched in this patch? It'd be kind of
annoying to get warnings from both flags for the same code...

Reply via email to