comp.lang.ada
 help / color / mirror / Atom feed
From: "David C. Hoos, Sr." <david.c.hoos.sr@ada95.com>
To: "Lurker" <nowhere@nothing.com>
Cc: comp.lang.ada@ada-france.org
Subject: Re: Division by zero
Date: Sat, 11 Jun 2005 21:00:32 -0500
Date: 2005-06-11T21:00:32-05:00	[thread overview]
Message-ID: <mailman.16.1118541539.17633.comp.lang.ada@ada-france.org> (raw)
In-Reply-To: GiIqe.6662$U4.962926@news.xtra.co.nz

The reason for the difference is that because both terms of line 1
are known at compile time, the computation is performed at compile
time, and thus raises the exception.

Since the numerator of line 2 is a variable, the compiler does not
attempt any computation, and thus does not signal an error.

Constraint_Error will be raised at runtime.

----- Original Message ----- 
From: "Lurker" <nowhere@nothing.com>
Newsgroups: comp.lang.ada
To: <comp.lang.ada@ada-france.org>
Sent: June 11, 2005 4:03 PM
Subject: Division by zero


> Hi,
> 
> I'm curios about the problem which I discovered by accident.
> The code below is of course very much reduced to show
> the it:
> 
> function x(a: integer) return integer is
> 
> some_constant: constant := 0;
> 
> begin
> 
> -- return 1/some_constant; -- line 1
> 
> -- return a/some_constant; -- line 2
> 
> end;
> 
> 
> 
> If line 1 is uncommented compiler (Gnat 3.15 for Widows)
> 
> produces the expected error about division by zero.
> 
> If line 2 is uncommented it passes compilation with no problem.
> 
> Surely that's not right? Or did I miss something?
> 
> 
> 
> 
> _______________________________________________
> comp.lang.ada mailing list
> comp.lang.ada@ada-france.org
> http://www.ada-france.org/mailman/listinfo/comp.lang.ada
> 
>



  reply	other threads:[~2005-06-12  2:00 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. [this message]
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
     [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