Path: utzoo!utgpu!water!watmath!clyde!bellcore!decvax!decwrl!labrea!agate!ucbvax!bloom-beacon!athena.mit.edu!jfc From: jfc@athena.mit.edu (John F Carr) Newsgroups: comp.arch Subject: Re: RISC data alignment Message-ID: <3001@bloom-beacon.MIT.EDU> Date: 17 Feb 88 22:15:44 GMT References: <2635@calmasd.GE.COM> <28200092@ccvaxa> <496@ecrcvax.UUCP> Sender: daemon@bloom-beacon.MIT.EDU Reply-To: jfc@athena.mit.edu (John F Carr) Organization: Massachusetts Institute of Technology Lines: 31 In article <496@ecrcvax.UUCP> johng@ecrcvax.UUCP (John Gregor) writes: >In article <28200092@ccvaxa> aglew@ccvaxa.UUCP writes: }}I have often wanted an optimizing compiler that could take }}struct { long a; int b; long c; char d; } }}which is usually mapped into bytes as AAAABBxxCCCCDxxx }}(on a machine where misaligned accesses are penalized) }}and make it into AAAACCCCBBDx. }I would like that also, but don't call it a struct. Rearranging the order }breaks lots of code and violates K&R p. 196. } } Within a structure, the objects declared have addresses } which increase as their declarations are read left-to-right. Isn't code which depends on allignment and spacing risky anyway? If a program assumes that for struct { int a; int b; } s; (&(s.a) - &(s.b)) == 1 it is making an unsupported assumption. Can someone post an example of a program which is portable and depends on the K&R rule quoted above? --John Carr (jfc@ATHENA.MIT.EDU)