Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!think!ima!haddock!karl From: karl@haddock Newsgroups: net.lang.c Subject: Re: Structure alignment question Message-ID: <86900047@haddock> Date: Mon, 8-Sep-86 16:48:00 EDT Article-I.D.: haddock.86900047 Posted: Mon Sep 8 16:48:00 1986 Date-Received: Mon, 8-Sep-86 20:52:49 EDT References: <3550@brl-smoke.ARPA> Lines: 16 Nf-ID: #R:brl-smoke.ARPA:3550:haddock:86900047:000:841 Nf-From: haddock!karl Sep 8 16:48:00 1986 rbbb@rice.EDU (David) writes: >C compilers that I have seen supporting structure-valued functions pass a >hidden parameter to the function containing the address to store the result. >Can a compiler assume that the storage for the result is word-aligned? >(That is, can a compiler make the same assumptions when returning a >structure that it does when assigning a structure?) Certainly. It can make this assumption for *any* expression of type "pointer to struct foo", whether it's explicit or (as in this example) generated by the compiler. *All* instances of a type (including those generated by a pointer dereference) have the alignment of that type. The user can sometimes circumvent this (type punning with casts or unions), but the result is undefined. Karl W. Z. Heuer (ima!haddock!karl; karl@haddock.isc.com), The Walking Lint