comp.lang.ada
 help / color / mirror / Atom feed
From: robert_dewar@my-dejanews.com
Subject: Re: Alternate to Unchecked_Conversion - Portable?
Date: 1999/02/22
Date: 1999-02-22T00:00:00+00:00	[thread overview]
Message-ID: <7aqe04$uhl$1@nnrp1.dejanews.com> (raw)
In-Reply-To: 36d05e39.0@news.pacifier.com

In article <36d05e39.0@news.pacifier.com>,
  "Steve Doiel" <nospam_steved@pacifier.com> wrote:
> I discovered a technique for performing a similar
> function to Unchecked_Conversion.  Locating two data
> structures at the same address by defining the first
> normally and then using an address clause to locate the
> second at the same address as the first (as shown in the
> following sample):
>
> My question is: is this portable?

Answer: this technique is standard and well known in Ada
95, though it was always wrong (erroneous) in Ada 83. It
is definitely NOT portable, and in particular, and
optimizer may get confused by the implicit aliasing, and
you cannot complain if it does!

> I expect that record layouts will be dependent on
> different endian machines, and I know that this technique
> is inherently unsafe, but it makes things very simple.

It is usually just as simple (from a reader's point of
view, and I sure hope that this is what you mean by simple)
to use unchecked conversion of pointers, and much better
defined, and likely to be more portable.

In general the use of overlays of this type should be
deprecated and used only if there is some very specific
reason to prefer this to the more standard unchecked
conversion approach.

P.S. the reason Ada 95 made this implementation dependent
rather than erroneous is that many (non-portable) Ada 83
programs used this technique, and it seemed pointless to
proscribe it as erroneous. However, it is ENTIRELY up to
the implementation to decide whether this is valid or not,
and an implementation that rejects it is indeed within its
rights. Unchecked conversion is likely to be far more
portable in practice.


-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    




  parent reply	other threads:[~1999-02-22  0:00 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-02-21  0:00 Alternate to Unchecked_Conversion - Portable? Steve Doiel
1999-02-21  0:00 ` Steve Quinlan
1999-02-22  0:00   ` robert_dewar
1999-02-21  0:00 ` Matthew Heaney
1999-02-22  0:00 ` Tom Moran
1999-02-22  0:00 ` robert_dewar [this message]
1999-02-22  0:00   ` Samuel Mize
1999-02-22  0:00 ` Christopher Green
1999-02-23  0:00   ` Matthew Heaney
1999-02-23  0:00     ` Samuel Mize
1999-02-24  0:00     ` robert_dewar
1999-02-25  0:00       ` Nick Roberts
1999-02-25  0:00         ` robert_dewar
1999-02-26  0:00           ` Nick Roberts
1999-02-26  0:00             ` Matthew Heaney
1999-02-27  0:00               ` Nick Roberts
1999-02-24  0:00   ` robert_dewar
1999-02-23  0:00     ` Christopher Green
1999-02-25  0:00       ` robert_dewar
1999-02-24  0:00         ` Christopher Green
1999-02-25  0:00           ` robert_dewar
1999-02-25  0:00             ` dennison
1999-02-25  0:00               ` Christopher Green
1999-02-26  0:00                 ` Tom Moran
1999-02-26  0:00                   ` robert_dewar
1999-02-26  0:00                 ` robert_dewar
1999-02-26  0:00                   ` Christopher Green
1999-03-01  0:00                     ` Nick Roberts
1999-03-01  0:00                       ` dewar
1999-03-01  0:00                         ` Nick Roberts
1999-02-26  0:00             ` Robert A Duff
1999-02-28  0:00               ` robert_dewar
1999-02-23  0:00     ` Christopher Green
1999-02-25  0:00       ` robert_dewar
1999-02-24  0:00         ` Christopher Green
1999-02-25  0:00           ` robert_dewar
1999-02-26  0:00             ` Dale Stanbrough
1999-02-26  0:00               ` Robert A Duff
replies disabled

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