Bug 19694 - [3.4 Regression] Warning about mismatched function declaration is now error
Summary: [3.4 Regression] Warning about mismatched function declaration is now error
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c (show other bugs)
Version: 3.4.3
: P2 normal
Target Milestone: 4.0.0
Assignee: Not yet assigned to anyone
URL:
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2005-01-29 16:17 UTC by Eli Zaretskii
Modified: 2005-04-30 00:06 UTC (History)
2 users (show)

See Also:
Host: i386-msdos-djgpp
Target: i386-msdos-djgpp
Build: i386-msdos-djgpp
Known to work: 4.0.0 3.3.3
Known to fail: 3.4.3
Last reconfirmed: 2005-01-29 16:23:01


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Eli Zaretskii 2005-01-29 16:18:00 UTC
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.
Comment 1 Andrew Pinski 2005-01-29 16:23:00 UTC
Confirmed, only a 3.4 regression, it works on the mainline (we get warnings and not errors).
Comment 2 Joseph S. Myers 2005-04-30 00:06:16 UTC
Fixed in 4.0.0.  c-decl.c in 3.4 was part way through a rewrite and
that intermediate version is fairly buggy and fragile, so backporting
fixes to that version seems inadvisable.