This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Implicit built-in function declarations
- From: Geoffrey Keating <geoffk at geoffk dot org>
- To: "Joseph S. Myers" <jsm at polyomino dot org dot uk>
- Cc: gcc at gcc dot gnu dot org
- Date: 01 Aug 2004 22:20:03 -0700
- Subject: Re: Implicit built-in function declarations
- References: <Pine.LNX.4.58.0408012208490.17049@digraph.polyomino.org.uk>
"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.