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,c4cb2c432feebd9d X-Google-Thread: 1094ba,c4cb2c432feebd9d X-Google-Attributes: gid103376,gid1094ba,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news2.google.com!newsfeed.gamma.ru!Gamma.RU!sn-xt-sjc-02!sn-xt-sjc-12!sn-xt-sjc-08!sn-post-sjc-01!supernews.com!news.supernews.com!nospam From: nospam@see.signature (Richard Maine) Newsgroups: comp.lang.ada,comp.lang.fortran Subject: Re: Bounds Check Overhead Date: Fri, 26 May 2006 09:18:31 -0700 Organization: Posted via Supernews, http://www.supernews.com Message-ID: <1hfxsjh.t88mchrssv9cN%nospam@see.signature> References: <0ugu4e.4i7.ln@hunter.axlog.fr> <%P_cg.155733$eR6.26337@bgtnsc04-news.ops.worldnet.att.net> <6H9dg.10258$S7.9150@news-server.bigpond.net.au> <1hfv5wb.1x4ab1tbdzk7eN%nospam@see.signature> <4475DA61.3080001@comcast.net> <44762F55.4050106@cits1.stanford.edu> <87hd3d1472.fsf@ludovic-brenta.org> User-Agent: MacSOUP/2.7 (Mac OS X version 10.4.4) X-Complaints-To: abuse@supernews.com Xref: g2news2.google.com comp.lang.ada:4499 comp.lang.fortran:10296 Date: 2006-05-26T09:18:31-07:00 List-Id: Ludovic Brenta wrote: > You seem to imply that Fortran has a similar rule, [that an loop index shall not change within a loop] > but that compilers > do not enforce that rule, and therefore have to perform range checking > to enforce a non-existent language rule about array access. I am > confused. Could you clarify? Others have replied some, but let me make my attempt at clarification because yes, you seem to be confused about multiple related things here. Yes, there is a Fortran language rule that a loop index shall not be changed while a loop is executing. Compilers are not required to enforce that rule, but essentially all compilers make at least some attempt to enforce it and catch the simple cases, which is most cases, but not all. There are cases where the violation of the rule is hard to detect, because the change occurs in some other procedure. But you talk about a "non-existent language rule about array access". It is not non-existent. There is a language rule prohibiting array access out of bounds. Brooks' point (and a good point it was, I thought) was that the rules on array bounds an loop index changes were similar in that both are rules that the compiler is not to required to enforce. Fortran has many, many such rules. In fact, that is how most of the Fortran language rules are. There is even a general statement to that effect near the front of the Fortran standard - that requirements and prohibitions generally apply to the programm rather than to the compiler. It is the program that is prohibitted from exceeding array bounds or changing loop indices, or doing all kinds of other things. The compiler is not responsable for enforcing it. There are some things that a compiler is required to enforce, but it is a small subset of all the requirements of the language. Although not stated in these terms, the subset is basically those things that can reasonably be expected to be detected at compile time with typical compiler implementations (which includes separate compilation of external procedures). The standard mostly doesn't require run-time checks, and it doesn't require compile-time ones that are particularly "difficult" (ie. that would require flow analysis, interprocedural analysis, or other things like that). Things like syntax errors, on the other hand, are usually required to be diagnosable. Compilers almost always go farther than the strict requirement of the standard. Any compiler that had no diagnostic capability other than that required by the standard would be commercially unviable. You probably could not give it way (literally). In the current case, almost all compilers will detect the simple and common cases of changing a DO loop index inside of the loop. That one tends to be a compile-time test looking for the syntactically obvious case of the change occuring in the source code physically in range of the loop. Likewise almost all compilers have the capability of detecting most array bounds violations. That one tends to be mostly done at run-time (some simple cases are caught at compile-time, but that's not the usual cases), and it tends to be optional to turn on the test. Some compilers also miss the harder cases, while other compilers can catch absolutely all cases. There is feature differentation between compilers in that area. -- Richard Maine | Good judgement comes from experience; email: last name at domain . net | experience comes from bad judgement. domain: summertriangle | -- Mark Twain