chris@mimsy.umd.edu (Chris Torek) (05/02/90)
In article <24003@mimsy.umd.edu> I wrote: >(You should get a diagnostic for this ... because the type of &a is >(char *(*)[10]), while the type of ptr is (char *(*)[]), and the numbers >in the brackets do not match.) Norman Diamond has pointed out that the ANSI C standard says otherwise: a pointer to an incomplete array type (one without a size) is compatible with a pointer to a complete array type of any size, provided that the types match when the size is not considered. In other words, a pointer of type T (*)[] is compatible with both one of type T (*)[10] and T (*)[20] , and a pointer of type T (*)[3] is compatible with one of type T (*)[] . This does not, however, affect my original point: there is nothing you can do with a pointer of type (T (*)[]) that you cannot do with one of type (T *), except confuse a human reading your code. (There *is* something new you can do if you put a number inside the brackets. This rule should be applied only to pointers to `sizeless' arrays.) -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163) Domain: chris@cs.umd.edu Path: uunet!mimsy!chris