comp.lang.ada
 help / color / mirror / Atom feed
From: "AG" <ang@xtra.co.nz>
Subject: Re: Pragma Volatile
Date: Tue, 2 Oct 2001 21:38:54 +1200
Date: 2001-10-02T21:38:54+12:00	[thread overview]
Message-ID: <fVfu7.147$jc1.20018@news.xtra.co.nz> (raw)
In-Reply-To: 5ee5b646.0109300510.71255128@posting.google.com


"Robert Dewar" <dewar@gnat.com> wrote in message
news:5ee5b646.0109300510.71255128@posting.google.com...

>
> I often find people making this kind of assumption, and
> in the case of reads I saw one awful bug caused by this:
>
>
>     type R is array (natural range <>) of Boolean;
>     pragma Pack (R);
>
>     Register : R (1 .. 32);
>     for Register'Address use ...
>
>     ...
>
>     B := Register (3);
>
> one compiler generated a word load, and extracted bit 3.
> another compiler generated a byte load, and extracted bit 3 from the
> byte.
>
> Both code sequences are perfectly valid, and just as
> efficient as one another. But the hardware had been
> build to require word loads, and byte loads were don't
> care and put the hardware into some obscure state.
>

Isn't it true that a compiler that puts it's target machine into
some obscure state can't be called perfectly valid? After all,
it is the job of the compiler to either produce a valid code or
reject what isn't possible. Can you really call a code sequence
(generated by a compiler with no control by the programmer)
"perfectly valid" if it sends the target machine from here to
"some obscure state"?

> But of course the real bug is in the implicit assumption
> in the code.

Well, that may be a bug in the assumptions in the code, but
it also looks like a compiler bug in so far that it accepted and
(mis)implemented those assumptions.






  parent reply	other threads:[~2001-10-02  9:38 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-09-25 14:07 Pragma Volatile Jon R. Harshaw
2001-09-25 14:23 ` David C. Hoos
2001-09-25 14:38 ` Marin David Condic
2001-09-25 23:03 ` Mark Johnson
2001-09-29 17:38   ` Tucker Taft
2001-09-29 18:22     ` minyard
2001-09-29 22:28       ` Jeffrey Carter
2001-09-30 13:10         ` Robert Dewar
2001-09-30 21:19           ` Jeffrey Carter
2001-10-01  2:58             ` minyard
2001-10-02  9:38           ` AG [this message]
2001-10-02 10:59             ` Jeff Creem
2001-09-30  2:03       ` DuckE
2001-09-30 13:01       ` Robert Dewar
2001-09-30 20:12         ` minyard
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox