comp.lang.ada
 help / color / mirror / Atom feed
From: sampson@nosc.mil (Charles H. Sampson)
Subject: Re: Fortran's Equivalence
Date: 1997/04/08
Date: 1997-04-08T00:00:00+00:00	[thread overview]
Message-ID: <1997Apr8.155111.26714@nosc.mil> (raw)
In-Reply-To: 3349165C.3B93@cae.ca


In article <3349165C.3B93@cae.ca>, Viqar Abbasi  <viqar@cae.ca> wrote:
> ...
>
>My original reason for this post was because when I received the code, 
>it used address clause overlays.  However, on my GNAT 3.07 for SGI, the 
>overlaying didn't work (or at least, that particular code have the 
>wrong results).  So, I added a routine for bit swapping, (localizing the 
>effect of changing machines to that one small routine), and then 
>proceeded with Unchecked_Conversion.  Later, when I downloaded GNAT 
>3.09, I found that it offered a whole new spectrum of address clause 
>flexibility.  A quick test showed me that the old address clause overlay 
>would work.  So, I thought I'd ask about the "preferred method" to do 
>something which I knew is dangerous.  (And actually, I've never used 
>EQUIVALENCE in a Fortran program... But I knew about it. :)
>
     Great!  An actual example of my repeated claim that the behavior 
of erroneous constructs can change from one version of a compiler to the 
next.  Admittedly, from your point of view this change was an improve-
ment, but it was a change nonetheless.
>
>record My_Record is
>    A:  some_type;
>    B:  some_other_type;
>    C:  still_another_type;
>end record;
>for My_Record_Type'Size use 32;
>for My_Record_Type use
>  record
>    A at 0 range 0 .. 14;
>    B at 0 range 15 .. 24;
>    C at 0 range 25 .. 31;
>  end record;
>
>Does "range 0 .. 14" mean the Most Signicant Bits?  Or does it mean 
>"Left most bits"?  This will clearly have an impact on my overlays.  If 
>I'm going to move bits arouund, then I don't want to have to change the 
>record representation clauses...  Will I be able to avoid it, by 
>only changing my bit-manipulation routine, depending on my machine?

     The bit order depends on the compiler.  If you want to do the ex-
tra work, you can code your record representation clauses to depend on 
one or more constant objects which you then set to appropriate values 
when transporting.

				Charlie





  reply	other threads:[~1997-04-08  0:00 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-03-25  0:00 Fortran's Equivalence Viqar Abbasi
1997-03-26  0:00 ` Robert Dewar
1997-03-26  0:00   ` Robert A Duff
1997-03-29  0:00   ` Matthew Heaney
1997-03-29  0:00     ` Robert Dewar
1997-04-02  0:00       ` JP Thornley
1997-03-26  0:00 ` FORTRAN's Equivalence Nick Roberts
1997-03-26  0:00 ` Fortran's Equivalence Michael F Brenner
1997-03-26  0:00   ` Larry Kilgallen
1997-03-28  0:00   ` Oliver Kellogg
1997-03-29  0:00   ` Matthew Heaney
1997-03-29  0:00     ` Robert Dewar
1997-04-01  0:00       ` Keith Thompson
1997-04-01  0:00         ` Robert Dewar
1997-04-01  0:00           ` Robert A Duff
1997-04-01  0:00             ` Robert Dewar
1997-04-04  0:00           ` Keith Thompson
1997-04-04  0:00             ` Keith Thompson
1997-04-04  0:00               ` Robert Dewar
1997-04-08  0:00                 ` Keith Thompson
1997-04-04  0:00             ` Robert Dewar
1997-04-07  0:00               ` Keith Thompson
1997-04-07  0:00               ` Charles H. Sampson
1997-04-07  0:00               ` Viqar Abbasi
1997-04-08  0:00                 ` Charles H. Sampson [this message]
1997-04-08  0:00                   ` Matthew Heaney
1997-04-09  0:00                     ` Stephen Leake
1997-04-09  0:00                       ` Robert Dewar
1997-04-10  0:00                         ` Simon Wright
1997-04-10  0:00                           ` Robert Dewar
1997-04-08  0:00                   ` Robert Dewar
     [not found]                     ` <1997Apr15.163103.27481@nosc.mil>
1997-04-16  0:00                       ` Robert Dewar
1997-04-07  0:00             ` Charles H. Sampson
1997-03-29  0:00     ` Robert Dewar
1997-03-26  0:00 ` Tom Moran
1997-03-28  0:00 ` Charles H. Sampson
1997-03-29  0:00   ` Matthew Heaney
1997-04-01  0:00     ` Charles H. Sampson
1997-03-29  0:00 ` Matthew Heaney
1997-03-29  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