Integer overflow and underflow semantics?
Basile Burg via Digitalmars-d
digitalmars-d at puremagic.com
Mon Jul 21 06:54:11 PDT 2014
On Wednesday, 16 July 2014 at 21:26:41 UTC, Gary Willoughby wrote:
> This was asked a few years ago and i could find a definitive
> answer.
>
> http://forum.dlang.org/thread/jo2c0a$31hh$1@digitalmars.com
>
> On Saturday, 5 May 2012 at 04:57:48 UTC, Alex Rønne Petersen
> wrote:
>> I don't think the language really makes it clear whether
>> overflows and underflows are well-defined. Do we guarantee
>> that for any integral type T, T.max + 1 == T.min and T.min - 1
>> == T.max?
>
> What is the current situation of integer overflow and underflow?
If you still feel ok today then dont read this:
-----------------
module meh;
import std.stdio;
//https://stackoverflow.com/questions/24676375/why-does-int-i-1024-1024-1024-1024-compile-without-error
static shared immutable int o = 1024 * 1024 * 1024 * 1024;
void main(string args[])
{
writeln(o);
}
-------------------------------------------------------------
More information about the Digitalmars-d
mailing list