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=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!feeder.eternal-september.org!nntp-feed.chiark.greenend.org.uk!ewrotcd!newsfeed.xs3.de!io.xs3.de!news.jacob-sparre.dk!franka.jacob-sparre.dk!pnx.dk!.POSTED.rrsoftware.com!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: Examining individual bytes of an integer Date: Mon, 15 Oct 2018 15:27:41 -0500 Organization: JSA Research & Innovation Message-ID: References: <9d90fa3e-f800-4086-bf97-a65474a8140a@googlegroups.com> <4f2fb3ba-9cca-46ad-b970-ccbcb7d08a2c@googlegroups.com> Injection-Date: Mon, 15 Oct 2018 20:27:41 -0000 (UTC) Injection-Info: franka.jacob-sparre.dk; posting-host="rrsoftware.com:24.196.82.226"; logging-data="19404"; mail-complaints-to="news@jacob-sparre.dk" X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-RFC2646: Format=Flowed; Original X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.7246 Xref: reader02.eternal-september.org comp.lang.ada:54600 Date: 2018-10-15T15:27:41-05:00 List-Id: "Matt Borchers" wrote in message news:4f2fb3ba-9cca-46ad-b970-ccbcb7d08a2c@googlegroups.com... > Does anybody ever do this kind of thing? Yes, and they should be drawn-and-quartered. :-) > procedure Main is > > type Byte is mod 256; > type Word is mod 2 ** 32; > > type E2 is array(1 .. 4) of Byte; > > Z: Word; > Y: E2; > for Y'Address use Z'Address; This sort of thing either destroys optimization (if it choses to pay attention to it) or destroys your code (if it doesn't). In particular, Z'Address is not required to be meaningful for objects that aren't aliased or by-reference (which Z is not above). (See 13.3(16).) Z might get placed into a register or optimized away completely, in which case Z'Address references nothing. You could of course declare Z as aliased: Z : aliased Word; but then you're guarenteeing worse code than you would get from one of the other methods. (Address clauses are almost always implemented with a level of indirection, because of their potentially dynamic nature.)] Randy.