comp.lang.ada
 help / color / mirror / Atom feed
From: kst@king.cts.com (Keith Thompson)
Subject: Re: Elaboration_check For Instantiations
Date: 1997/10/28
Date: 1997-10-28T00:00:00+00:00	[thread overview]
Message-ID: <878068940.763599@wagasa.cts.com> (raw)
In-Reply-To: 1997Oct28.192057.29122@nosc.mil


Charles H. Sampson (csampson@cod.nosc.mil) wrote:
[...]
>      You are right, the GNAT implementation is entirely correct.  I 
> must have mislead you when I said "technically correct".  Technically 
> correct is correct, no doubt about it.  All I meant was that GNAT is not 
> following the programmer's wishes.  If Suppress(Elaboration_check) is 
> written, then the programmer doesn't want the check made; if the check 
> is not made then Program_error can't be raised.  The programmer's wisdom 
> in making such a request is another discussion.
> 
>  				Charlie

As is the programmer's wisdom in assuming that pragma Suppress means
the check won't be made.

The intent of pragma Suppress is to improve the efficiency of generated
code by inhibiting checks that the programmer knows will not fail.
Suppressing a check that would fail if it were not suppressed, as in
the following:

    X : Some_Integer_Subtype := Some_Integer_Subtype'Last;

    declare
	pragma Suppress(Range_Check);
    begin
	X := X + 1;
    end;

is a misuse of the pragma, and results in erroneous execution (and
arbitrarily nasty results).  For example, the compiler is entitled to
assume that X is in the range of its subtype after the assignment, and
to perform optimizations based on that assumption.  The more clever the
compiler, and the more aggressively it optimizes, the more likely it is
to mess things up.

References:

RM95-11.5(26):
    If a given check has been suppressed, and the corresponding error
    situation occurs, the execution of the program is erroneous.

RM95-11.5(29) (a note):
    There is no guarantee that a suppressed check is actually removed;
    hence a pragma Suppress should be used only for efficience reasons.

-- 
Keith Thompson (The_Other_Keith) kst@cts.com <*>
^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H
San Diego, California, USA
"Simba, you have forgotten me.  I am your father.  This is CNN." -- JEJ




  reply	other threads:[~1997-10-28  0:00 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-10-23  0:00 Elaboration_check For Instantiations Charles H. Sampson
1997-10-23  0:00 ` Charles H. Sampson
1997-10-24  0:00   ` Tucker Taft
1997-10-24  0:00     ` Robert Dewar
1997-10-27  0:00       ` Charles H. Sampson
1997-10-27  0:00         ` Robert Dewar
1997-10-28  0:00           ` Charles H. Sampson
1997-10-28  0:00             ` Keith Thompson [this message]
1997-10-28  0:00               ` Charles H. Sampson
1997-10-29  0:00                 ` W. Wesley Groleau x4923
1997-10-29  0:00                   ` Tom Moran
1997-10-30  0:00                     ` Larry Kilgallen
1997-10-30  0:00                   ` Charles H. Sampson
     [not found]                   ` <345774b3.1434102@santaclara01.news.internex.net>
1997-10-30  0:00                     ` Charles H. Sampson
1997-10-29  0:00                 ` Robert Dewar
1997-10-29  0:00                   ` Charles H. Sampson
1997-10-29  0:00             ` Robert Dewar
1997-10-27  0:00     ` Charles H. Sampson
1997-10-27  0:00       ` Robert Dewar
1997-10-24  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