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-Thread: 101deb,15c6ed4b761968e6 X-Google-Attributes: gid103376,gid1094ba,gid101deb,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news1.google.com!news4.google.com!news.glorb.com!news-in.ntli.net!newsrout1-win.ntli.net!ntli.net!news.highwinds-media.com!newspeer1-win.ntli.net!newsfe4-gui.ntli.net.POSTED!53ab2750!not-for-mail From: "Dr. Adrian Wrigley" Subject: Re: Ada vs Fortran for scientific applications User-Agent: Pan/0.14.2 (This is not a psychotic episode. It's a cleansing moment of clarity.) Message-Id: Newsgroups: comp.lang.ada,comp.lang.fortran,comp.lang.pl1 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> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit Date: Thu, 25 May 2006 12:09:59 GMT NNTP-Posting-Host: 82.10.238.153 X-Trace: newsfe4-gui.ntli.net 1148558999 82.10.238.153 (Thu, 25 May 2006 13:09:59 BST) NNTP-Posting-Date: Thu, 25 May 2006 13:09:59 BST Organization: NTL Xref: g2news2.google.com comp.lang.ada:4453 comp.lang.fortran:10236 comp.lang.pl1:1699 Date: 2006-05-25T12:09:59+00:00 List-Id: On Wed, 24 May 2006 23:04:03 -0700, Richard Maine wrote: > Nasser Abbasi wrote: > >> I just did this simple test, declare an array and go overbound and see if we >> get a run-time error: > ... >> $ g95 f.f90 > ... >> $ <------------------- NO runtime ERROR > > This part of the thread has started drifting away from relevance to much > of anything, but that particular sample is just drifting yet further. It > illustrates neither much about subscript bounds rules being part of the > language nor about bounds checking being part of the language, which > were the two topics mentioned earlier in the subthread. > > Instead, the example illustrates only that g95 does not have the bounds > check option enabled by default, which is yet a third question (and one > mentioned in more generality earlier). > > As with most compilers, g95 does have a bounds check option; it just > isn't enabled by default. Compiling your same example, but asking for > bounds checking, gets it. In particular, compiling and running your > example code on my Mac here with > > g95 -fbounds-check clf.f90 > ./a.out > > Gives me: > > At line 4 of file clf.f90 > Traceback: not available, compile with -ftrace=frame or -ftrace=full > Fortran runtime error: Array element out of bounds: 11 in (1:10), dim=1 > > which is, in fact, more detailed than the message you showed from gnat. > (Turning on the trace options gets rid of the message about not having > one, but it is trivial and adds nothing else useful for this example.) Bounds checking code is not needed if it can be proved never to fail. Sometimes the compiler can do that. Sometimes the programmer can do that, even if the compiler can't. This is why the *source code* should be able to disable and re-enable checks with fine granularity. Programmers can comment the code as to why checks are unnecessary and disable them. This fine-grain control over checking needs to be standardized across compilers, otherwise source files become non-portable. (note: IIRC, the Ariane 5 launch failure was linked to disabling a range check after careful analysis... of Ariane 4 trajectory) A couple of questions about Fortran: Are bounds check failures trappable in a standard way so the program can continue? Can it be controlled on a finer grain than per compilation? Do user defined numerical types have restricted bounds too? The adverse consequences of exceeding bounds can be seen to outweigh the (usually) modest costs in code size and performance that even mature code should ship with checks enabled, IMO. Compilers generally should be shipped with the 'failsafe' options on by default. -- Adrian