Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!lll-crg!mordor!sri-spam!rutgers!clyde!ima!haddock!karl From: karl@haddock.UUCP (Karl Heuer) Newsgroups: comp.lang.c Subject: Re: structure element offsets Message-ID: <191@haddock.UUCP> Date: Tue, 9-Dec-86 23:46:59 EST Article-I.D.: haddock.191 Posted: Tue Dec 9 23:46:59 1986 Date-Received: Wed, 10-Dec-86 12:28:23 EST References: <1096@spice.cs.cmu.edu> <7377@utzoo.UUCP> <427@viper.UUCP> Reply-To: karl@haddock.ISC.COM.UUCP (Karl Heuer) Organization: Interactive Systems, Boston Lines: 16 Summary: use of malloc is portable In article <427@viper.UUCP> dave@viper.UUCP (David Messer) writes: It is >interesting in that the only thing gaurenteed about casts on pointers is the >conversion to a long and back and conversion to a pointer to a smaller type >and back, which also results in the same original pointer value. One >interesting thing is, by these rules, the use of malloc(), for anything other >than char arrays, is non-portable. No, it isn't. The *implementation* of malloc() is nonportable, but since it is guaranteed to return a maximally-aligned "char *" (the result of casting a widetype pointer, which, as you mentioned, may be safely cast back), its use is portable. (Well, I guess if you want to nit-pick, the rules you quoted don't specifically allow (int *)(char *)(double *)double_aligned_intptr; is that what you mean?) Karl W. Z. Heuer (ima!haddock!karl or karl@haddock.isc.com), The Walking Lint