comp.lang.ada
 help / color / mirror / Atom feed
From: "Chris Sparks (Mr. Ada)" <sparks@AISF.COM>
Subject: Re: stuff
Date: 1997/05/16
Date: 1997-05-16T00:00:00+00:00	[thread overview]
Message-ID: <337C8911.6BD@aisf.com> (raw)
In-Reply-To: md5:AEB770CC4F41F9C14E5056EEB8BA8D66


I received this e-mail from a fellow engineer.  I thought it was worthy
of flaming! :-)

> In searching for an answer for the problem report C970502-2892 regarding
> uninitialized variables, I discovered the following problem.
>
> Using ADA3.3 on OSF4.0 (and also ADA3.2 on OSF3.2G), I compiled the follwing
> source code with these options:
>
>    $setenv ADALISFLAGS "+m"; ada -A"@adalib" -g3 -O3 -i1 -V uninit.ada
>
> The source code is:
> =========================================================
>
> FUNCTION Test RETURN INTEGER IS
>
>    ui1 : INTEGER;
>    ui2 : INTEGER;
>    i3  : INTEGER := 2468;
>
>    bool : BOOLEAN := FALSE;
>
> BEGIN
>
>    IF bool THEN
>       ui1 := 5;
>    END IF;
>
>    ui2 := 1;
>    i3  := 3;
>
>    RETURN(ui1 + ui2 + i3);
>
> END Test;
>
> =========================================================
>
> The output listing file contains this:
>
> =========================================================
> Test   Machine Code Listing  2-May-1997 13:00:50  DEC Ada V3.3-9-318O
> 01     Test                  2-May-1997 13:36:15  uninit.ada
>
>                                 .section $CODE$, OCTA, exe, nord, nowrt
>              0000       Test::
                        >                     ; 000001
> 47E13400     0000               mov     9, r0  ; 9, r0
>                     ; 000021
> 6BFA8001     0004               ret     r26    ; r26
> =========================================================
>
> The instruction generated by the compiler "mov  9, r0" is incorrect.  The
> compiler should not assume that variable ui1 = 5 when the program runs, since
> bool will always be false.
>
> Although this code snippet may not be a "real world" example, I am concerned
> that the compiler error that is causing this may affect a more common
> ADA construct.  Please let me know the scope of this problem and possible
> fixes/suggestions.
>
> =============================================================================
> 5/7/97
>
> Paul Hill from DEC support requests the code snippet above.  Sent
> to his email at p_hill@csc32.cxo.dec.com.

I, myself, tried this with GNAT 3.09 under HP-UX 10.20.  When I compiled
it (gcc -O2)
I expected to be told that U1 was basically unitialized and that the
assignment on
return would be undefined.

Why isn't this program erroneous?  It certainly is not safe!

Chris Sparks




       reply	other threads:[~1997-05-16  0:00 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <md5:AEB770CC4F41F9C14E5056EEB8BA8D66>
1997-05-16  0:00 ` Chris Sparks (Mr. Ada) [this message]
1997-05-16  0:00   ` stuff Samuel A. Mize
1997-05-16  0:00     ` stuff Robert Dewar
1997-05-19  0:00       ` stuff Samuel A. Mize
1997-05-17  0:00   ` stuff Robert A Duff
1997-05-18  0:00     ` stuff Nick Roberts
replies disabled

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