Article View: gnu.gcc.bug
Article #1753Re: Bug with functions as parameters?
From: Dave Hanson
Date: Wed, 05 Oct 1988 22:22
Date: Wed, 05 Oct 1988 22:22
22 lines
1293 bytes
1293 bytes
In article <8810051813.AA01101@uther.cs.purdue.edu> spaf@PURDUE.EDU (Gene Spafford) writes:
>Index:
> gcc 1.28 on a Sun 3/50, 3/60, 3/280 all running 3.4 SunOS
>
>Source to reproduce problem:
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.
not quite. foo is defined in `old-style' and hence there's no argument
checking done for calls to foo like the foo(bar).
also, the type of argument x is automatically converted from
`int function' to `pointer to int function' as stipulated at the
top of p. 218 in K&R2.
hence, there are no errors.
Technical Details
Message-ID:
<12426@princeton.Princeton.EDU>Path:
arc1-ca.pugleaf.net!utzoo!telly!ddsw1!mcdchg!rutgers!njin!princeton!notecnirp!drhReferences:
<8810051813.AA01101@uther.cs.purdue.edu>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!telly!ddsw1!mcdchg!rutgers!njin!princeton!notecnirp!drh From: drh@notecnirp.Princeton.EDU (Dave Hanson) Newsgroups: gnu.gcc.bug Subject: Re: Bug with functions as parameters? Message-ID: <12426@princeton.Princeton.EDU> Date: 5 Oct 88 22:22:10 GMT References: <8810051813.AA01101@uther.cs.purdue.edu> Sender: news@princeton.Princeton.EDU Reply-To: drh@notecnirp.UUCP (Dave Hanson) Distribution: gnu Organization: Dept. of Computer Science, Princeton University Lines: 22