comp.lang.ada
 help / color / mirror / Atom feed
From: tmoran@bix.com (Tom Moran)
Subject: Re: Alternate to Unchecked_Conversion - Portable?
Date: 1999/02/22
Date: 1999-02-22T00:00:00+00:00	[thread overview]
Message-ID: <36d09fd9.15766741@news.pacbell.net> (raw)
In-Reply-To: 36d05e39.0@news.pacifier.com

>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
>...
>My question is: is this portable?
  You have similar record layout worries with address overlay and
Unchecked_Conversion.  If you use a representation clause to control
all the parts of the layout, then the two layouts should be the same -
if you don't, then two compilers would be free to make them different.
It seems unlikely two compilers would choose different endian-ness for
multi-byte entities on the same machine, but clearly they might on
different machines, so IO is a worry.  If you're careful and thorough,
you should be able to make something portable, but you ought to check
the compilers you're using (and again when you get a newer version of
either compiler).. 
  With Unchecked_Conversion, at least the compiler can warn you if the
two things aren't the same size, which of course it can't if they
merely have the same address.  If some later change modifies the
layout or adds to the size of one of the two things, the compiler
can't give you any warnings.
  With Unchecked_Conversion, the only time you transform one object
into another is when you call the instantiated Unchecked_Conversion
function.  With the address overlay, you've got aliasing and possibly
multitasking to worry about - any change to either object is instantly
reflected in the other, and any change to a temporary compiler
generated copy (in registers, say) of one object fails to be reflected
in the other.
  With Unchecked_Conversion, it's easy to use your editor to find any
occurrences, and then occurrences of the instantiated conversion.
With address overlay, you can find the rep clauses, and then the
objects, but following them through their aliases (as one is passed to
a procedure either by reference or by copy in/out, say) will get real
tedious and error prone.
  With Unchecked_Conversion, you have a function able to transform
*any* object of the one type to the other.  With address overlay, you
have a single specific object transformed implicitly to another single
specific object.
  That said, yes there do exist times when address overlay is the
best, or only, thing to do.
  
 






  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 ` Matthew Heaney
1999-02-21  0:00 ` Steve Quinlan
1999-02-22  0:00   ` robert_dewar
1999-02-22  0:00 ` Tom Moran [this message]
1999-02-22  0:00 ` robert_dewar
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-26  0:00             ` Dale Stanbrough
1999-02-26  0:00               ` Robert A Duff
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
replies disabled

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