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.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no 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!news3.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newscon06.news.prodigy.com!prodigy.net!newsdst02.news.prodigy.com!prodigy.com!postmaster.news.prodigy.com!newssvr11.news.prodigy.com.POSTED!2febb241!not-for-mail Reply-To: "Nasser Abbasi" From: "Nasser Abbasi" Newsgroups: comp.lang.ada,comp.lang.fortran 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> <1hfxsjh.t88mchrssv9cN%nospam@see.signature> Subject: Re: Bounds Check Overhead X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.2869 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2869 X-RFC2646: Format=Flowed; Original Message-ID: NNTP-Posting-Host: 69.235.235.207 X-Complaints-To: abuse@prodigy.net X-Trace: newssvr11.news.prodigy.com 1148664659 ST000 69.235.235.207 (Fri, 26 May 2006 13:30:59 EDT) NNTP-Posting-Date: Fri, 26 May 2006 13:30:59 EDT Organization: SBC http://yahoo.sbc.com X-UserInfo1: [[PGGYCEFZRYB_LYLRKF__PAUSXB@DTMNHWB_EYLJZ]BGIELCNSKQFCY@TXDX_WHSVB]ZEJLSNY\^J[CUVSA_QLFC^RQHUPH[P[NRWCCMLSNPOD_ESALHUK@TDFUZHBLJ\XGKL^NXA\EVHSP[D_C^B_^JCX^W]CHBAX]POG@SSAZQ\LE[DCNMUPG_VSC@VJM Date: Fri, 26 May 2006 17:30:59 GMT Xref: g2news2.google.com comp.lang.ada:4501 comp.lang.fortran:10298 Date: 2006-05-26T17:30:59+00:00 List-Id: "Richard Maine" wrote in message news:1hfxsjh.t88mchrssv9cN%nospam@see.signature... > 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. > Hello; I am not sure if there is supposed to compiler flag to enforce this or not, you do not seem to imply that, so I did this very simple test, please see: ------------ test for checking on changing loop index---- $ cat a.f90 PROGRAM MAIN DO I=1,10 CALL foo(I) PRINT *,I END DO END PROGRAM SUBROUTINE foo(I) I=I+1 END SUBROUTINE ------------- end program ------ $ g95 a.f90 $ ./a.exe 2 4 6 8 10 12 14 16 18 20 --------- end run --------- I did the same in Ada: --------- Ada ------- procedure Main is PROCEDURE foo(I: in out integer) IS begin I:=I+1; end foo; BEGIN FOR I IN 1..10 LOOP foo(I); END LOOP; END Main; ------- end ada ---- The above will not even be allowed to compile since Ada wants 'I' to be an actual variable. The compile error I get is "actual for I must be a variable" This means I am not even allowed to use "I" in a call. This eliminate the problem from accidentally change the loop counter. Nasser