This is the mail archive of the
mailing list for the GCC project.
Re: Ada subtypes and base types
- From: Laurent GUERBY <laurent at guerby dot net>
- To: Waldek Hebisch <hebisch at math dot uni dot wroc dot pl>
- Cc: Robert Dewar <dewar at adacore dot com>, law at redhat dot com, gcc at gcc dot gnu dot org
- Date: Fri, 17 Mar 2006 20:32:28 +0100
- Subject: Re: Ada subtypes and base types
- References: <E1FKFbv-0001nQfirstname.lastname@example.org>
On Fri, 2006-03-17 at 15:07 +0100, Waldek Hebisch wrote:
> Robert Dewar wrote:
> > Laurent GUERBY wrote:
> > > On Mon, 2006-03-13 at 15:31 -0700, Jeffrey A Law wrote:
> > >> On Mon, 2006-02-27 at 20:08 +0100, Waldek Hebisch wrote:
> > >>
> > >>> What do you mean by "abuse"? TYPE_MAX_VALUE means maximal value
> > >>> allowed by given type.
> > >> As long as you're *absolutely* clear that a variable with a
> > >> restricted range can never hold a value outside that the
> > >> restricted range in a conforming program, then I'll back off
> > >> the "abuse" label and merely call it pointless :-)
> > >
> > > Variables in a non erroneous Ada program all have their value between
> > > their type bounds from the optimizer perspective (the special 'valid
> > > case put aside).
> > Not quite right. If you have an uninitialized variable, the value is
> > invalid and may be out of bounds, but this is a bounded error situation,
> > not an erroneous program. So the possible effects are definitely NOT
> > unbounded, and the use of such values cannot turn a program erroneous.
> > (that's an Ada 95 change, this used to be erroneous in Ada 83).
> What about initializing _all_ variables?
In Ada this is the effect of the configuration pragma Normalize_Scalars
H.1 Pragma Normalize_Scalars
1 This pragma ensures that an otherwise uninitialized scalar object is set
to a predictable value, but out of range if possible.
1.a Discussion: The goal of the pragma is to reduce the impact of a
bounded error that results from a reference to an uninitialized
scalar object, by having such a reference violate a range check and
thus raise Constraint_Error.
2 The form of a pragma Normalize_Scalars is as follows:
3 pragma Normalize_Scalars;