comp.lang.ada
 help / color / mirror / Atom feed
From: bloom-picayune.mit.edu!enterpoop.mit.edu!snorkelwacker.mit.edu!tamsun.tam u.edu!cs.utexas.edu!convex!sercely@bloom-beacon.mit.edu  (Ron Sercely)
Subject: Re: Uninitialized subtype variables
Date: 22 Oct 92 17:38:11 GMT	[thread overview]
Message-ID: <1992Oct22.173811.5455@convex.com> (raw)

In article <1992Oct21.234759.24972@beaver.cs.washington.edu> pattis@cs.washingt
on.edu (Richard Pattis) writes:
>I cannot find anything in the LRM (mostly around 3.2.1) for Ada that says
>after elaborating 
>   X : NATURAL;
>X's value is guaranteed to be >= 0. Is this in fact correct? Is there even a
>guarantee that the bit pattern it contains can be interpreted as a
>legal INTEGER?
>
>Now, suppose I also declared PROCEDURE P (N : NATURAL); A smart compiler
>could avoid checking the parameter constraint when calling P(X). But this coul
d
>lead to some interesting errors if X truly contained a negative value from its
>(lack of) initialization.
>
>Any comments?
>
>------------------------------------------------------------------------------
>  Richard E. Pattis

You are correct.  The elaboration of x: natural; 
makes NO guarantee about the bit pattern in the memory associated with x,
and that this does indeed lead to interesting errors, as compilers do often
optimize away checks because the "know" that the value must be positive.

The bottom line is that programs that read from un-initialized variables
are erroneous.  Some compilers will warn you about potential use before
assignment.

Ron Sercely

             reply	other threads:[~1992-10-22 17:38 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1992-10-22 17:38 bloom-picayune.mit.edu!enterpoop.mit.edu!snorkelwacker.mit.edu!tamsun.tam [this message]
  -- strict thread matches above, loose matches on Subject: below --
1992-10-27  1:26 Uninitialized subtype variables Robert I. Eachus
1992-10-27  1:22 munnari.oz.au!ariel!ucsvc.ucs.unimelb.edu.au!phillip.edu.au!dale
1992-10-25 11:37 math.fu-berlin.de!news.netmbx.de!Germany.EU.net!mcsun!sunic!seunet!enea!s
1992-10-24 18:44 Alex Blakemore
1992-10-23 20:43 Michael Feldman
1992-10-23 16:49 cis.ohio-state.edu!news.sei.cmu.edu!ajpo.sei.cmu.edu!falis
1992-10-22 13:46 cis.ohio-state.edu!zaphod.mps.ohio-state.edu!wupost!micro-heart-of-gold.m
1992-10-21 23:47 Richard Pattis
replies disabled

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