Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!brl-adm!brl-smoke!smoke!rbbb@rice.EDU From: rbbb@rice.EDU (David Chase) Newsgroups: net.lang.c Subject: Structure alignment question Message-ID: <3550@brl-smoke.ARPA> Date: Thu, 4-Sep-86 14:07:55 EDT Article-I.D.: brl-smok.3550 Posted: Thu Sep 4 14:07:55 1986 Date-Received: Fri, 5-Sep-86 06:47:33 EDT Sender: news@brl-smoke.ARPA Lines: 26 Suppose I have a structure "foo" and function returning a "struct foo". struct foo { int a,b; }; struct foo bar() { struct foo baz; ... return baz; }; Note that the structure contains two ints. I will assume that an "int" is the same size as some machine quantity called a "word", and that word alignment is desirable. I assume therefore that all instances of the structure generated by the compiler will be word-aligned. 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?) If so, why? If not, why not? David