From mboxrd@z Thu Jan 1 00:00:00 1970 From: dmr@plan9.bell-labs.com To: 9fans@cse.psu.edu Subject: Re: [9fans] thread MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Message-Id: <20010706055512.42D78199D7@mail.cse.psu.edu> Date: Fri, 6 Jul 2001 01:55:09 -0400 Topicbox-Message-UUID: c33b37c0-eac9-11e9-9e20-41e7f4b1d025 So far as I can determine, the Plan 9 C compiler is conformant here. If you have, say, an int A[10]; then just A is the address of A and has type int *. &A is a pointer to this array of 10 integers; it will have the same value, as a pointer, but a different type: int (*)[10] The reason why the initialization in the thread man page, (and presumably the code) works is that the thing being assigned to is void *, and any object pointer will fit; the coercion just happens. The & in &m is redundant, probably misleading, but ultimately harmless. Kenji's example with print likewise has the same character, since print is a variadic function, and all his second arguments fall under the ... in its declaration, and so aren't type-checked. Incidentally, there is no C-language guarantee that the actual bit pattern produced by A and &A will be identical, though in practice they usually will be for most compilers, yet they still have different types. For a case in which the type-checking is more evident, without the laxness of void * or ..., try compiling #include #include void t1(int *ip); void t2(int (*iap)[10]); void main(void) { int ia[10]; t1(ia); t1(&ia); t2(ia); t2(&ia); } You will get errors on lines 13 [ t1(&ia) ] and 14 [ t2(ia) ]. Dennis