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=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,2a34b7ad6c6a0774 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!news2.google.com!news.glorb.com!news2.euro.net!newsfeed.freenet.ag!news.netcologne.de!ramfeed1.netcologne.de!newsfeed.arcor.de!newsspool2.arcor-online.net!news.arcor.de.POSTED!not-for-mail Date: Tue, 10 Aug 2010 17:10:08 +0200 From: Georg Bauhaus User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.2.8) Gecko/20100802 Thunderbird/3.1.2 MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Efficiency of code generated by Ada compilers References: <8349c981-4dca-49dc-9189-8ea726234de3@f42g2000yqn.googlegroups.com> In-Reply-To: <8349c981-4dca-49dc-9189-8ea726234de3@f42g2000yqn.googlegroups.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit Message-ID: <4c616bd0$0$6765$9b4e6d93@newsspool3.arcor-online.net> Organization: Arcor NNTP-Posting-Date: 10 Aug 2010 17:10:08 CEST NNTP-Posting-Host: fb71a167.newsspool3.arcor-online.net X-Trace: DXC=lbjbLbf2Ua2NTD55K=McF=Q^Z^V384Fo<]lROoR18kF:Lh>_cHTX3j=]fPcRgS`l]1 X-Complaints-To: usenet-abuse@arcor.de Xref: g2news1.google.com comp.lang.ada:13073 Date: 2010-08-10T17:10:08+02:00 List-Id: On 10.08.10 15:52, Elias Salom�o Helou Neto wrote: > On Aug 7, 4:53 am, "Dmitry A. Kazakov" > wrote: >> On Fri, 6 Aug 2010 13:21:48 -0700 (PDT), Elias Salom�o Helou Neto wrote: >> >>> I would like to know how does code generated by Ada compilers compare >>> to those generated by C++. >> >> The short answer is yes, of course. >> >> The long answer is that such comparisons are quite difficult to perform >> accurately. > > Yes, I know that. I am, however, writing code within that 1% of > applications that would be tremendously affected if there is no way to > access arrays with no range checking. So I am asking very precisely: > does Ada allow me to do non range-checked access to arrays? Yes. The language mandates that checks can be turned off. See LRM 11.5, for example, of how to give permission. You can document this is source text by placing a language defined pragma Suppress in some scope. (There is also a pragma Unsuppress!) Compilers can be advised to turn checks on or off, either specific checks, or all checks. To see the effects, get GNAT or some other compiler; with GNAT, translate the same source with suitable options and look at the code generated in each case. $ gnatmake -c -O2 -funroll-loops -gnatn -gnatp a.adb vs $ gnatmake -c -gnato -fstack-check -gnata a.adb procedure A is pragma Suppress (Range_Check); -- or All_Checks type My_Index is range 10 .. 55; subtype Only_Some is My_Index range 10 .. 12; type A_Few_Bucks is digits 4; type Data is array (My_Index range <>) of A_Few_Bucks; subtype Few_Data is Data (Only_Some); X, Y, Z: Few_Data; begin X := Few_Data'(1.2, 3.4, 5.6); Y := Few_Data'(3.21, 0.19, 3.3E+12); -- hand made sum placed in Z: for K in Z'Range loop Z(K) := X(K) + Y(K); end loop; pragma Assert (Z(10) in 4.4 .. 4.5 and Z(11) in 3.5 .. 3.6 and Z(12) >= 3.3E+12); end A;