https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67386

--- Comment #1 from joseph at codesourcery dot com <joseph at codesourcery dot 
com> ---
On Fri, 28 Aug 2015, msebor at gcc dot gnu.org wrote:

> GCC isn't completely consistent in diagnosing references to undeclared
> functions.  In the test case below, it issues an error for only the last three
> out of the four definitions of foo.  It issues a warning for the first one,
> even though it too references an undeclared identifier.

This is a consequence of C90 implicit declarations being accepted as an 
extension in C11 mode.  The implicit declaration from the call in the 
first case is in scope for the non-call reference.  In no other case is 
there a declaration, even implicit, in scope for such a reference.

> Versions prior to 5.1 diagnosed only the second and fourth forms.

Previous versions defaulted to gnu89.  In C99 and later, each half of an 
if statement has its own scope; before C99, the scope of the implicit 
declaration in case 3 would have been the whole of the body of the 
function.

Reply via email to