From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,55f243f32a97dc7e X-Google-Attributes: gid103376,public From: dewar@merv.cs.nyu.edu (Robert Dewar) Subject: Re: Elaboration_check For Instantiations Date: 1997/10/27 Message-ID: #1/1 X-Deja-AN: 286129848 References: <1997Oct23.205254.25272@nosc.mil> <1997Oct27.223135.2373@nosc.mil> X-Complaints-To: usenet@news.nyu.edu X-Trace: news.nyu.edu 877998336 8023 (None) 128.122.140.58 Organization: New York University Newsgroups: comp.lang.ada Date: 1997-10-27T00:00:00+00:00 List-Id: Charlie says << Are you sure about that, Robert? (Never fearing, he leaps back into the fray.) 11.5(2) says that language-defined checks, which in- clude Elaboration_check, have to be made at run time and 3.11(14) says that Program_error is raised if Elaboration_check fails. Of course, 11.5(1) says that pragma Suppress "gives permission to an implementation" to omit the check, so the GNAT implementation is technically correct, at least.>> You are making a common mistake, GNAT is entirely correct. Detecting a check that fails at compile time and compiling the appropriate raise is of course completely permissible, and indeed highly desirable (note that annex H requires that a compiler that *does* detect such a situation at compile time *must* output a warning). Why is this correct? Becuase it is behaviorally equivalent to doing the check at runtime. I often find that people do not understand the critical as-if principle that applies to all compiler code generation. This is such a case. Generating the raise of PE behaves *exactly* "as if" the check were done at runtime and is therefore fine. The whole point of 11.5(1) allowing you NOT to omit the check is precisely to deal with cases like this, where it would take extra time and code to omit the check. The purpose of Suppress is to permit the compiler to speed up the code by omitting the check. It is *NOT* to guarantee that the exception will not be raised. So, yes, I am 100% sure!