Article View: gnu.gcc.bug
Article #1752Bug with functions as parameters?
From: Gene Spafford
Date: Wed, 05 Oct 1988 18:13
Date: Wed, 05 Oct 1988 18:13
44 lines
1372 bytes
1372 bytes
Index:
gcc 1.28 on a Sun 3/50, 3/60, 3/280 all running 3.4 SunOS
Source to reproduce problem:
#include <stdio.h>
int bar ()
{
printf("hi!\n");
}
void foo (x)
int x ();
{
x();
}
int main()
{
foo(bar);
}
As I understand both K&R C and the new draft, this program should
not compile because the declaration of "int x ()" should conflict
with the parameter "x" provided as an argument.
Sun "cc" correctly flags this as an error, but gcc does not.
(The correct declaration should be "int (*x) ();" )
Script:
Script started on Wed Oct 5 13:06:05 1988
uther(96)> cc bogus.c
"bogus.c", line 9: x declared as parameter to non-function
"bogus.c", line 9: warning: a function is declared as an argument
uther(97)> gcc -traditional bogus.c
uther(98)> gcc -ansi bogus.c
uther(99)> gcc -pedantic bogus.c
uther(100)> ./a.out
hi!
uther(101)> ^D
script done on Wed Oct 5 13:06:53 1988
Technical Details
Message-ID:
<8810051813.AA01101@uther.cs.purdue.edu>Path:
arc1-ca.pugleaf.net!utzoo!telly!ddsw1!mcdchg!rutgers!tut.cis.ohio-state.edu!PURDUE.EDU!spafShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!telly!ddsw1!mcdchg!rutgers!tut.cis.ohio-state.edu!PURDUE.EDU!spaf From: spaf@PURDUE.EDU (Gene Spafford) Newsgroups: gnu.gcc.bug Subject: Bug with functions as parameters? Message-ID: <8810051813.AA01101@uther.cs.purdue.edu> Date: 5 Oct 88 18:13:56 GMT Sender: daemon@tut.cis.ohio-state.edu Distribution: gnu Organization: SERC, Department of Computer Sciences, Purdue Univ. Lines: 44