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.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 Path: border1.nntp.dca.giganews.com!nntp.giganews.com!usenet.blueworldhosting.com!feeder01.blueworldhosting.com!feeder.erje.net!eu.feeder.erje.net!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: "J-P. Rosen" Newsgroups: comp.lang.ada Subject: Re: integers of 1, 2, 4 bytes Date: Mon, 16 Jun 2014 06:46:52 +0200 Organization: A noiseless patient Spider Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit Injection-Date: Mon, 16 Jun 2014 04:46:52 +0000 (UTC) Injection-Info: mx05.eternal-september.org; posting-host="2b3884a634d8f846e0712b4e3a92507a"; logging-data="14038"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+I9jA04q6my507g6zHzmek" User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 In-Reply-To: Cancel-Lock: sha1:mkxsD7d4r3Z+t9THq91W1lAwVLg= X-Enigmail-Version: 1.6 Xref: number.nntp.dca.giganews.com comp.lang.ada:186950 Date: 2014-06-16T06:46:52+02:00 List-Id: Le 15/06/2014 23:25, hreba a écrit : > All I want is: > 1. Same behaviour of translated program and original > 2. Avoid unnecessary range checks. > [...] > > 2. Avoid unnecessary range checks. > > From what I read I had understood the following: Subtypes are always > range checked, and in addition there are overflow checks. When my > subtype boundaries are equal to the limits of the base type, one of the > checks is redundant. I have nothing against checks and I don't have > performance issues, I just wanted to avoid _unnecessary_ checks. > The Ada model requires checks; however, if a check is unnecessary (i.e. statically provable as never failing), the compiler is allowed to remove it, and in practice Ada compilers are quite good at removing unnecessary checks. More generally, the design of Ada took great care at not preventing optimization. So you should not worry about that kind of optimization, and let the compiler do it for you. And if you still have doubts, compile the same program with and without checks, and compare the timings; in general you'll be surprised by how small the difference is. That's precisely because the compiler removes all /unnecessary/ checks. All that remains are the /necessary/ checks; that's why in Ada, you generally keep the tests in the delivered version. -- J-P. Rosen Adalog 2 rue du Docteur Lombard, 92441 Issy-les-Moulineaux CEDEX Tel: +33 1 45 29 21 52, Fax: +33 1 45 29 25 00 http://www.adalog.fr