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!news4.google.com!news.glorb.com!newsfeed2.telusplanet.net!newsfeed.telus.net!edtnps89.POSTED!53ab2750!not-for-mail From: Gordon Sande Newsgroups: comp.lang.ada,comp.lang.fortran,comp.lang.pl1 Message-ID: <2006052509454116807-gsande@worldnetattnet> 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; format=flowed Content-Transfer-Encoding: 8bit Subject: Re: Ada vs Fortran for scientific applications User-Agent: Unison/1.7.5 Date: Thu, 25 May 2006 12:45:41 GMT NNTP-Posting-Host: 24.89.210.20 X-Trace: edtnps89 1148561141 24.89.210.20 (Thu, 25 May 2006 06:45:41 MDT) NNTP-Posting-Date: Thu, 25 May 2006 06:45:41 MDT Xref: g2news2.google.com comp.lang.ada:4456 comp.lang.fortran:10238 comp.lang.pl1:1700 Date: 2006-05-25T12:45:41+00:00 List-Id: On 2006-05-25 09:09:59 -0300, "Dr. Adrian Wrigley" said: > 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? I am a big fan of subscript checking and undefined variable checking. I have found that all of the errors that these aids have found have been in parts of my programs that I believed to be free of such errors because I had looked hard at them some time before. Either I had not done a good job of looking or the assumptions underlying the look had changed. That seems to be the nature of the beast. I can avoid (usually!) the trival bugs. I like getting help once the bug is not trivial. (Maybe that is a definition of trivial.) Fine grained control would have been of no use, and in fact harmful, if I had tried to use it. My take is it makes a great checklist feature that may help get past "desired feature checklists" but is otherwise not of any real benefit. The check is great but fine grained control is not. > Do user defined numerical types have restricted bounds too? That is a Pascal-like feature that I miss in Fortran. So I do my own checking. Because of my problem domain I have to be proactive in checking parameter values on entry to new procedures even if the invocation is from one that has already checked. The buzz word is programming by contract if I have read the programming fashion of the day rags. How many Ada systems can match the undefined variable checking of the old WatFor or the current Salford CheckMate or the Lahey/Fujitsu global checking? It seems to be a thing associated with places that run student cafteria computing on mainframes. Not much used anymore. There was a similar student checkout PL/I from Cornell if I recall correctly. > 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.