From: Robert A Duff <bobduff@shell01.TheWorld.com>
Subject: Re: Division by zero
Date: 29 Jun 2005 09:40:16 -0400
Date: 2005-06-29T09:40:16-04:00 [thread overview]
Message-ID: <wccd5q5gu2n.fsf@shell01.TheWorld.com> (raw)
In-Reply-To: dGtwe.11236$U4.1433098@news.xtra.co.nz
"Lurker" <nowhere@nothing.com> writes:
> "Robert A Duff" <bobduff@shell01.TheWorld.com> 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
next prev parent reply other threads:[~2005-06-29 13:40 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-06-11 21:03 Division by zero Lurker
2005-06-12 2:00 ` David C. Hoos, Sr.
2005-06-12 3:04 ` Lurker
2005-06-12 8:39 ` Dmitry A. Kazakov
2005-06-12 9:43 ` Lurker
2005-06-12 10:36 ` Marius Amado Alves
2005-06-12 11:53 ` Dmitry A. Kazakov
2005-06-13 8:03 ` Ole-Hjalmar Kristensen
2005-06-12 13:10 ` Robert A Duff
2005-06-12 16:55 ` Jeffrey Carter
2005-06-13 3:22 ` Keith Thompson
2005-06-14 2:14 ` Jeffrey Carter
2005-06-13 8:47 ` Lurker
2005-06-14 2:19 ` Jeffrey Carter
2005-06-14 8:35 ` Keith Thompson
2005-06-13 12:19 ` Robert A Duff
2005-06-14 2:31 ` Jeffrey Carter
2005-06-14 8:21 ` Lurker
2005-06-14 20:22 ` Randy Brukardt
2005-06-28 21:22 ` Robert A Duff
2005-06-29 5:50 ` Lurker
2005-06-29 13:27 ` Robert A Duff
2005-06-29 13:54 ` Dmitry A. Kazakov
2005-06-29 16:03 ` Robert A Duff
2005-06-30 1:19 ` Lurker
2005-06-30 11:16 ` Stuart Palin
2005-06-29 13:50 ` Dmitry A. Kazakov
2005-06-29 16:07 ` Robert A Duff
2005-06-30 8:27 ` Dmitry A. Kazakov
2005-06-29 9:20 ` Lurker
2005-06-29 9:49 ` Christoph Grein
2005-06-29 10:40 ` Lurker
2005-06-29 11:04 ` Jeff Creem
2005-06-29 12:28 ` Martin Dowie
2005-06-29 13:40 ` Robert A Duff [this message]
[not found] ` <5sana1pm436l6vboifijqblu0irf84afkr@4ax.com>
2005-06-12 17:38 ` Simon Wright
2005-06-12 12:21 ` Robert A Duff
2005-06-12 22:53 ` Georg Bauhaus
2005-06-13 8:34 ` Lurker
2005-06-13 8:54 ` Marius Amado Alves
2005-06-13 17:59 ` Simon Wright
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox