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: 1014db,9adfbb907494972e X-Google-Attributes: gid1014db,public X-Google-Thread: 103376,9adfbb907494972e X-Google-Attributes: gid103376,public From: ok@goanna.cs.rmit.edu.au (Richard A. O'Keefe) Subject: Re: Ada to C/C++ translator needed Date: 1996/10/01 Message-ID: <52q47q$m8j@goanna.cs.rmit.edu.au>#1/1 X-Deja-AN: 186379671 references: <32499FA0.4B5E@magic.fr> <52e5t5$m28@btmpjg.god.bel.alcatel.be> <52feul$os2@goanna.cs.rmit.edu.au> <01bbad6e$67743f20$32ee6fcf@timhome2> <52ltk5$qlf@news1.halcyon.com> <01bbae25$67c669a0$32ee6fcf@timhome2> <01bbae8f$dffbd440$32ee6fcf@timhome2> organization: Comp Sci, RMIT, Melbourne, Australia newsgroups: comp.lang.c,comp.lang.ada nntp-posting-user: ok Date: 1996-10-01T00:00:00+00:00 List-Id: "Tim Behrendsen" writes: >I know that Ada does run-time checks of array bounds that C >doesn't do; that could be one source of loss of performance. >Does Ada do any other run-time checks that C doesn't do? It is seriously misleading to say that Ada "does" run-time checks that C doesn't. To start with, there are (very useful) C implementations that do bounds checks at run time, and the C standard was carefully crafted to allow this (one possible area of conflict was the struct hack, but it has been rules that the struct hack is not legal C any more). The second point is that bounds checks can very often be eliminated by the optimiser. This is an *old* result (the first mention I saw of it was in one of the SETL papers back in the early 70s). It should be obvious that for I in A'Range loop ... use A(I) ... end loop; isn't going to need any range checks, even when the bounds of A are dynamic. A lot of Ada array references are of this form. A recent paper which I think was talking about Fortran (the relevant proceedings are not in this office right now) claimed 95% elimination. And to finish, pragma Suppress can be used to request supression of many checks, including bounds checks. It's win-win: you get the *choice*. -- Australian citizen since 14 August 1996. *Now* I can vote the xxxs out! Richard A. O'Keefe; http://www.cs.rmit.edu.au/%7Eok; RMIT Comp.Sci.