Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!seismo!ut-sally!utah-cs!utah-gr!uplherc!nrc-ut!caeco!john From: john@caeco.UUCP (John Rigby) Newsgroups: comp.lang.c Subject: Re: char (*a)[] (was: Style [++i vs i++]) Message-ID: <193@caeco.UUCP> Date: Fri, 14-Aug-87 12:14:45 EDT Article-I.D.: caeco.193 Posted: Fri Aug 14 12:14:45 1987 Date-Received: Sun, 16-Aug-87 11:52:30 EDT References: <234@nvpna1.UUCP> Organization: CAECO Inc., Salt Lake City, Utah Lines: 51 About the program main(a) char (*a)[]; { a = 0; print("%x\n"); a++; print("%x\n"); } in article <234@nvpna1.UUCP>, strouckn@nvpna1.UUCP (Louis Stroucken 42720) says: > > K&R appendix A section 10.4 says on array arguments: > ...formal parameters declared "array of..." are adjusted to read > "pointer to...". > > The declaration of "a" might as well read "char **a;". "a++;" should > increment "a" with sizeof( char * ) bytes. > > If I miss something, please let me know. "a" is NOT an array. It is a pointer to an array. As such, your argument is invalid. in article <189@xyzzy.UUCP>, throopw@xyzzy.UUCP (Wayne A. Throop) says: > > But the scariest thing about all this is that *none* *of* *my* *tools* > *caught* *this* *bug*!!!! Lint happily passed the program, as did other > typecheckers. And the compiler didn't complain (though on our system > the output is > > a=0x0 > a=0x1 > On my machine (Sun 3-260 running 3.2) both the compiler and lint give the same warning: warning: zero-length array element And the output is: a=0x0 a=0x0 Which makes sence since the size is zero. John Rigby !utah-cs!caeco!john CAECO Inc. Salt Lake City, UT