From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=0.2 required=5.0 tests=BAYES_00,INVALID_MSGID, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,b23661223cdab88a X-Google-Attributes: gid103376,public From: kilgallen@eisner.decus.org (Larry Kilgallen) Subject: Re: Representation clauses and records Date: 1997/12/16 Message-ID: <1997Dec16.061148.1@eisner>#1/1 X-Deja-AN: 298667781 X-Nntp-Posting-Host: eisner.decus.org References: <347000b1.4909762@news.geccs.gecm.com> <349646A2.1A013246@alphalink.com.au> X-Trace: news.decus.org 882270712 7673 KILGALLEN [192.67.173.2] Organization: LJK Software Reply-To: Kilgallen@eisner.decus.org.nospam Newsgroups: comp.lang.ada Date: 1997-12-16T00:00:00+00:00 List-Id: In article <349646A2.1A013246@alphalink.com.au>, Pascal MALAISE writes: > In C or ADA, you are likely to get a bus error or an unaligned access, > more or less recovered by the operating system or your application :-( > > This is because processors make assumptions about the addresses of given > data types: > character/byte - any address > 16 bits "word" - address is a multiple of 2 > 32 bits "int" - address is is a multiple of 4 > 64 bits "long" - address is a multiple of 8 > > When you declare your array of bytes/characaters, the compiler > implements > the array starting at any address. When you cast, the compiler will > consider the new (integer) data as aligned and the processor will trap. Whether the compiler (for any language) assumes that such variables are aligned depends on the quality of the compiler and what you have told it. The DEC compilers for various languages on Alpha have many hooks for indicating what assumptions should be made regarding alignment. The result is to tune the generated code between that which presumes worst case alignment and that which presumes best case alignment. Larry Kilgallen