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=-0.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,12a7e74c384c0acb,start X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.224.213.1 with SMTP id gu1mr14464986qab.7.1348623234809; Tue, 25 Sep 2012 18:33:54 -0700 (PDT) Received: by 10.236.176.103 with SMTP id a67mr2534554yhm.2.1348623234765; Tue, 25 Sep 2012 18:33:54 -0700 (PDT) Path: e10ni53868478qan.0!nntp.google.com!l8no10839030qao.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Tue, 25 Sep 2012 18:33:54 -0700 (PDT) Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=70.192.195.128; posting-account=oVfT5woAAABM-b9_p2pX0lyTMvmsmxo_ NNTP-Posting-Host: 70.192.195.128 User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <5a0711d8-81ad-4200-9b6e-a80feffd5302@googlegroups.com> Subject: optimization away of checks in 'valid From: Joseph Wisniewski Injection-Date: Wed, 26 Sep 2012 01:33:54 +0000 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Date: 2012-09-25T18:33:54-07:00 List-Id: Ran into an issue with one compiler having to do with the implementation of= 'valid. Was looking for comments as to how other compilers handle this.=20 Basically, the question is, if 'valid is called on an integer object, are t= here conditions under which some of the checks done by 'valid (range checki= ng on an object of an integer subtype) are removed? Specifically, we had a case where C++ code was not checking the bounds of a= integer subtype as it was passed to Ada code via a function parameter. The= Ada code _was_ checking via 'valid. 'valid returned true even though the i= nteger value was out of bounds. Turns out the compiler relied on the "allow= ed assumption" that all callers "check their bounds" for such data. As such= , the range checks in 'valid were eliminated as redundant as part of buildi= ng with optimization on. In fact, I believe the checks were eliminated unde= r no-opt also.=20 My question is whether this is similar behavior across compilers or if 'val= id is viewed as always performing the same checks, including and perhaps es= peciallyh bounds checks in this kind of situation.