From: l107353@cliffy.lfwc.lockheed.com (Garlington KE)
Subject: Re: Optimizing and Constraint Checks
Date: 24 Mar 1995 20:15:28 GMT
Date: 1995-03-24T20:15:28+00:00 [thread overview]
Message-ID: <3kv990$o7d@butch.lmsc.lockheed.com> (raw)
In-Reply-To: edward-2303951004270001@r-618macip27.hac.com
Ed Bruce (edward@igate1.hac.com) wrote:
: I am currently attempting to implement a safe, portable
: Unchecked_Conversion of an enumerated type to integer and from an integer
: type back to the enumeration. The following code shows the current
: solution, the question raised by one engineer is can we guarantee the the
: return statement in the To_Enum function is portable. That is may a
: compiler optimize away the ENUM'Pos and ENUM'Val and effectively eliminate
: the constraint check.
I think your first portability problem is whether the ENUM will fit into an
INTEGER. My compiler manual says: "Objects of enumeration types are allocated
one word when no representation specification is given. If a specification
is given that uses values in the range of LONG_INTEGER (but outside the
range of INTEGER), objects will be allocated in double words.
Second, I could definitely see a compiler optimizing away 'Val('Pos). 'Valid
would be a better attribute here.
Third, if an enum spec is used, I'm not sure what happens if there are holes
in the underlying number sequence. The LRM says that CONSTRANT_ERROR is
raised if X'Val is not in the _range_ T'POS(T'BASE'FIRST) ..
T'POS(T'BASE'LAST). If it's in range, but not a valid representation, I
suspect different compilers might behave differently.
--------------------------------------------------------------------
Ken Garlington GarlingtonKE@lfwc.lockheed.com
F-22 Computer Resources Lockheed Fort Worth Co.
If LFWC or the F-22 program has any opinions, they aren't telling me.
next prev parent reply other threads:[~1995-03-24 20:15 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
1995-03-23 16:04 Optimizing and Constraint Checks Ed Bruce
1995-03-24 13:34 ` Theodore Dennison
1995-03-25 18:09 ` David Wheeler
1995-03-29 0:00 ` Ed Bruce
1995-03-24 20:15 ` Garlington KE [this message]
1995-03-26 12:01 ` Robert Dewar
1995-03-27 16:58 ` Garlington KE
1995-03-29 0:00 ` Ed Bruce
1995-03-29 0:00 ` Garlington KE
1995-03-30 0:00 ` Mike Meier
1995-04-04 0:00 ` Robert Dewar
1995-03-25 17:51 ` 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