Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!uwm.edu!cs.utexas.edu!uunet!aussie!rex From: rex@aussie.UUCP (Rex Jaeschke) Newsgroups: comp.std.c Subject: Re: compatibility of types Message-ID: <42.UUL1.3#5077@aussie.UUCP> Date: 11 Jul 90 21:29:48 GMT References: <1842@tkou02.enet.dec.com> Organization: Journal of C Language Translation Lines: 25 > diamond@tkou02.enet.dec.com (diamond@tkovoa) writes: > > However, you might want to beware of a subtle difference regarding > some types that you did not ask about. int(*)[3] and int(*)[5] also > point to integers, but they are not compatible with each other. > It's a bit too subtle for me to figure out if each is compatible > with int* or not. A pointer to an array of x int is NOT assignment-compatible to a pointer to an array of y int nor to a pointer to an int. You MUST use an explicit cast to compare/copy etc. them or to mix them when calling a function in the presence of such a prototype. It is conceivable that a pointer to an array might be a "fat" pointer containing information about the underlying array size giving it a different representation to a straight int pointer. Rex ---------------------------------------------------------------------------- Rex Jaeschke | Journal of C Language Translation | C Users Journal (703) 860-0091 | 2051 Swans Neck Way | DEC PROFESSIONAL uunet!aussie!rex | Reston, Virginia 22091, USA | Programmers Journal ---------------------------------------------------------------------------- Convener of the Numerical C Extensions Group (NCEG) ----------------------------------------------------------------------------