comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Integer overflow is int overflow (Re: Web browser in Ada)
Date: Tue, 27 Apr 2010 19:56:48 +0200
Date: 2010-04-27T19:56:46+02:00	[thread overview]
Message-ID: <3n2b0k6018j6.11197jmpw7kgs$.dlg@40tude.net> (raw)
In-Reply-To: 4bd71a58$0$6889$9b4e6d93@newsspool2.arcor-online.net

On Tue, 27 Apr 2010 19:09:43 +0200, Georg Bauhaus wrote:

> On 27.04.10 18:13, Dmitry A. Kazakov wrote:
> 
>> The value is determined by the expression and the
>> language rules.
> 
> (OK, nitpicking, there is no value denoted by a named number
> if determination does not actually happen. Words mean
> nothing unless they are given meaning. ;-) ;-)

Yes, but the meaning is given by the language rules, not by the running
instance of the compiler. Therefore:

   X : constant := 2**(2**(2**(2**1_000_000_000)));

is well-defined even if there likely will never exist a compiler-machine
combination capable to swallow it.

>> You need overflow in order to define the behavior of the operations closed
>> only in Z. E.g. "+".
> 
> True if it is not possible to define "+" in terms of saturation
> or wrap-around, I think. Correct?

"+" can be defined in any way. The question is the semantics of. If the
semantics of "+" is to model Z, then it cannot return a value from Z which
is mathematically wrong. The problem is not in a singular value. It is with
the programs that will use this value in other computations. In the end it
will break everything about Z. You won't be certain about any evaluated
value. Ideals like exceptions, NaN etc, limit the damage.
 
> However, programmers do not define "+" in their C programs.
> They use "+"!
> Then overflow occurs, and not to prove the soundness of the
> language definition, but as a mishap.

Yes. If the programmer is lucky then the behavior maps the implied
semantics. This is what we call "safe choice." Unfortunately C's choices
are often unsafe in the sense that the layman programmer's expectations are
far not what C actually does.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



  reply	other threads:[~2010-04-27 17:56 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-23  8:03 Web browser in Ada Gautier write-only
2010-04-23 13:56 ` Maciej Sobczak
2010-04-23 14:37   ` Georg Bauhaus
2010-04-27 11:41     ` Martin Krischik
2010-04-27 12:22       ` Georg Bauhaus
2010-04-27 14:00         ` AdaMagica
2010-04-27 15:30           ` Integer overflow is int overflow (Re: Web browser in Ada) Georg Bauhaus
2010-04-27 16:13             ` Dmitry A. Kazakov
2010-04-27 17:09               ` Georg Bauhaus
2010-04-27 17:56                 ` Dmitry A. Kazakov [this message]
2010-04-23 21:33   ` Web browser in Ada Gautier write-only
2010-04-24  0:38     ` Peter C. Chapin
2010-04-25  5:38       ` Gautier write-only
2010-04-25 16:24         ` Peter C. Chapin
2010-04-25 10:41       ` Georg Bauhaus
2010-04-25 16:29         ` Peter C. Chapin
2010-04-26 15:37       ` Warren
2010-04-24  9:51 ` leonid
2010-04-25  5:04   ` Gautier write-only
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox