Implicit built-in function declarations
Geoffrey Keating
geoffk@geoffk.org
Mon Aug 2 05:20:00 GMT 2004
"Joseph S. Myers" <jsm@polyomino.org.uk> writes:
> Part of a patch I'm testing for bug 13801 leads to mandatory warnings for
> implicit declarations of built-in functions (other than those in the
> implementation namespace ^_[_A-Z]) if the type of the implicit declaration
> is not compatible with the type of the built-in function. Are there any
> comments on this (that the warnings shouldn't be on by default, that they
> should be mandatory errors, ...)?
It should certainly not be a mandatory error. The most common case is
where there's a void/int mismatch in the return value, which is
harmless on most platforms.
I think a mandatory warning would be OK. It could only cause trouble
if -Werror is in use, and anyone who uses -Werror surely wants to know
about such things. (I'm even leaning towards the idea that -Wimplicit
should be on by default.)
> Note that all implicit declarations of built-in functions (not just those
> with incompatible types) have had warnings for some time at -Wall and by
> default in C99 mode.
>
> The most common instances in gcc.dg are for implicit declarations of abort
> and exit, but other functions involved (outside the tests for built-in
> functions) include printf, memcpy, strlen, memset, fabs and alloca; any
> built-in function with a return type that is not int, or which is
> variadic, or which has an argument changed by the default argument
> promotions, will receive the warning if implicitly declared.
More information about the Gcc
mailing list