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,e01fe1b326df26d4 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.google.com!newsread.com!news-xfer.newsread.com!news-feed01.roc.ny.frontiernet.net!nntp.frontiernet.net!newscon06.news.prodigy.com!prodigy.net!newsfeed-00.mathworks.com!nntp.TheWorld.com!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: Re: Division by zero Date: 29 Jun 2005 09:40:16 -0400 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: <79ahr0jozmqb$.10jzllrcjpmsv.dlg@40tude.net> <_pwre.7121$U4.1023104@news.xtra.co.nz> NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: pcls4.std.com 1120052418 426 192.74.137.71 (29 Jun 2005 13:40:18 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Wed, 29 Jun 2005 13:40:18 +0000 (UTC) User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 Xref: g2news1.google.com comp.lang.ada:11732 Date: 2005-06-29T09:40:16-04:00 List-Id: "Lurker" writes: > "Robert A Duff" wrote in message > news:wccy88ugorw.fsf@shell01.TheWorld.com... > > > 11.6(5) is all about run time effects. If divide by zero were illegal > > (which means at compile time), then 11.6 would not apply. 11.6 is also > > (as you said) all about implementation permissions -- i.e. not > > portable. I would hope a legality rule in this area would be portable. > > OK, I don't want to get *too* deep into the language wars sort > of thing. Language wars? To have a language war, you have to crosspost to two or more newsgroups, and insult the advocates of one or more languges. ;-) >... My surprise was quite pragmatic - I was called in (as a > consultant) to investigate and fix a problem that led to actual program > crash in production. The reason for that crash, as it happened, was > division by zero in some obscure and rarely used part of the code. > Now, I would understand it if it was a variable which is generally > unsolvable. But a constant? At first I thought it must be a bug in this > particular compiler version. But since then I've had quite a few replies > stating that's how it should be. So I don't know anymore... Whether it's a compiler bug or not is a matter of opinion. It depends whether you think compilers ought to be smart enough to detect the case you're interested in (which, as I recall, was something like X/0, where X is not static). I think it's a bug, and I would report it. You can convince the compile vendor that it's a bug by giving them money. ;-) But this case is *not* a violation of the Ada standard. The compiler *should* detect this case (IMHO), but is not required to do so by the standard. There are many other cases compilers *should* detect. For example: package P is Y: constant Integer; private Y: constant Integer := 0; end P; ... X/P.Y ... -- compiler should warn, but P.Y is *not* static and: procedure P(X: Integer) is Y: Integer; begin if ... then Y := 0; ... X/Y ... -- compiler should warn else Y := 7; end if; end P; I'm not sure about this one: procedure P(X: Integer) is Y: Integer; begin if ... then Y := 0; else Y := 7; end if; ... X/Y ... -- should compiler warn? end P; There's probably a bug, but maybe not. - Bob