Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!henry From: henry@utzoo.UUCP (Henry Spencer) Newsgroups: comp.lang.c Subject: Re: Determing alignment of (char *) pointer Message-ID: <7388@utzoo.UUCP> Date: Sat, 6-Dec-86 20:45:38 EST Article-I.D.: utzoo.7388 Posted: Sat Dec 6 20:45:38 1986 Date-Received: Sat, 6-Dec-86 20:45:38 EST References: <1510@mit-trillian.MIT.EDU>, <487@cartan.Berkeley.EDU> Organization: U of Toronto Zoology Lines: 15 > if (p != (char *) (long *) p) ... ? > This should give you the relevant information (can a long be stored at > the location pointed to by p?) without any machine dependencies. I suppose > on some (broken) compilers it might not work... Also on some non-broken compilers, alas. Converting "char *" to "long *" with a cast does not guarantee that the result is a VALID "long *". That is your problem, not the compiler's. On some machines this will work, because the conversion involves a change in representation, explicitly dropping the higher-precision part of the char pointer. But on orthodox machines like VAXen and 68Ks, the compiler makes no attempt to clear those nasty low-order bits, so the comparison tells you nothing. -- Henry Spencer @ U of Toronto Zoology {allegra,ihnp4,decvax,pyramid}!utzoo!henry