Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!seismo!sundc!sun!gorodish!guy From: guy%gorodish@Sun.COM (Guy Harris) Newsgroups: comp.unix.wizards Subject: Re: have I found a bug in K&R? Message-ID: <31164@sun.uucp> Date: Sun, 18-Oct-87 00:16:01 EDT Article-I.D.: sun.31164 Posted: Sun Oct 18 00:16:01 1987 Date-Received: Sun, 18-Oct-87 22:38:11 EDT References: <18668@amdcad.AMD.COM> <517@hubcap.UUCP> <321@laticorp.UUCP> <3802@elecvax.eecs.unsw.oz> Sender: news@sun.uucp Lines: 22 > This applies whether they are declared as formal parameters or as > external array declarations. I often declare functions like > fn(a,b) > char *a; > char b[]; > in order to *prevent* myself from changing b during the function. > It eliminates some coding errors by making the compiler do some > extra checking for me. Umm, guess again. K&R says, in 10.1 "External function definitions": ...Also, since a reference to an array in any context (in particular as an actual parameter) is taken to mean a pointer to the first element of the array, declarations of formal parameters declared ``array of ...'' are adjusted to read ``pointer to ...'''. Which means that the compiler will treat the declarations of "a" *and* "b" as declarations of pointers. Furthermore, PCC, at least, works this way, so most PCC-based compilers aren't doing any extra checking for you. Guy Harris {ihnp4, decvax, seismo, decwrl, ...}!sun!guy guy@sun.com