Consider the following source file:

static int
foo (arg1, arg2)
     void *arg1, *arg2;
{
  bar (arg1, arg2);
  return 0;
}

void
bar (arg1, arg2)
     void *arg1, *arg2;
{
  callme (arg1, arg2);
}

If I compile it with GCC 3.3.3 or earlier, I get a warning:

 tfwd.c:11: warning: type mismatch with previous implicit declaration
 tfwd.c:5: warning: previous implicit declaration of `bar'
 tfwd.c:11: warning: `bar' was previously implicitly declared to return `int'

But if I compile with 3.4.3, I get an error:

 tfwd.c:11: error: conflicting types for 'bar'
 tfwd.c:5: error: previous implicit declaration of 'bar' was here

I think this is a bug: GCC should not emit diagnostics for this code, certainly 
not flag it as an error, except perhaps under -ansi -pedantic.  There's nothing 
wrong with having a function defined after it is used; GCC should not force me 
write bottom-up code, nor add gratuitous prototypes for functions defined in 
the same source file where they are used.

-- 
           Summary: Warning about mismatched function declaration is now
                    error
           Product: gcc
           Version: 3.4.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: eliz at gnu dot org
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i386-msdos-djgpp
  GCC host triplet: i386-msdos-djgpp
GCC target triplet: i386-msdos-djgpp


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19694

Reply via email to