Bug? or do I something wrong

Steven Schveighoffer via Digitalmars-d digitalmars-d at puremagic.com
Wed Dec 30 12:13:46 PST 2015


On 12/30/15 9:07 AM, Daniel Kozak wrote:
> import std.stdio;
>
> void main() {
>
>      auto x = 9223372036854775807L;
>      auto x2 = 9223372036854775807L + 1;
>      long x3 = -9223372036854775808U;
>      //auto x4 = -9223372036854775808L; //Error: signed integer overflow

Not a bug.

This is parsed as - (9223372036854775808L)

That number cannot be represented in signed long, so it fails.

The only correct thing to do is via x3.

-Steve


More information about the Digitalmars-d mailing list