Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1a 12/4/83; site rlgvax.UUCP Path: utzoo!linus!decvax!harpo!seismo!rlgvax!guy From: guy@rlgvax.UUCP (Guy Harris) Newsgroups: net.lang.c Subject: Re: Re: Anyone on ANSI standard C - (nf) Message-ID: <1698@rlgvax.UUCP> Date: Fri, 10-Feb-84 00:17:46 EST Article-I.D.: rlgvax.1698 Posted: Fri Feb 10 00:17:46 1984 Date-Received: Sat, 11-Feb-84 06:02:15 EST References: <58@haddock.UUCP> Organization: CCI Office Systems Group, Reston, VA Lines: 29 > I have a question about the effects of specifying parameter types in > the ANSI C standard. What will the exact effect be when the type of an > actual parameter differs from the type given in the declaration? Seems to > me that while silently casting is usually the right thing, in some cases > the compiler should issue warnings because the odds are good the > user is making a mistake. I think the compiler should cast silently > if the declared and actual types are both arithmetic, regardless of > length or signed/unsigned distinctions (leave warnings about lost > accuracy to lint), or if the declared type is a pointer of any type and the > actual parameter is the constant 0, but warn the user about everything > else (e.g., using an int or char* where a FILE* was expected). That's actually an implementation question to some degree; the Portable C Compiler already issues warnings for the implicit conversions you mention. I.e., if you have int foo; char *bar; FILE *bletch; foo = bar; bletch = bar; you will get "Illegal combination of pointer and integer" for the first and "Illegal pointer combination" for the second. Any PCC-based implementation of ANSI C would probably do exactly this, which is what you suggest. Guy Harris {seismo,ihnp4,allegra}!rlgvax!guy