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


In article <878068940.763599@wagasa.cts.com>,
Keith Thompson <kst@king.cts.com> wrote:
>Charles H. Sampson (me) 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.

     A bunch of very good points and I certainly don't want to be put 
into the position of defending anyone who tries to achieve some result 
by an erroneous execution.  I'm big on writing portable code and errone-
ous programs (forgive the ellipsis) are anathema to me.  However, I have 
never been happy as a programmer when a compiler says, "I'm smarter than 
you are and I'm not going to allow you to do what you want."  When I was 
a compiler writer, I tried to keep my compilers from doing that.

     Now that doesn't quite apply to the current case, because the RM 
allows the programmer's "suggestion" to be ignored.  Nevertheless, it's 
very close in spirit.  The existence of Suppress(Elaboration_check) 
strongly indicates that the programmer wants the check suppressed, as 
does Suppress(Range_check).  Any argument about erroneousness that is 
applicable to the former can also be made for the latter.

 				Charlie

--
******

    If my user name appears as "csampson", remove the 'c' to get my
correct e-mail address.




  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
1997-10-28  0:00               ` Charles H. Sampson [this message]
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