Bug? or do I something wrong

Daniel Kozak via Digitalmars-d digitalmars-d at puremagic.com
Wed Dec 30 12:23:23 PST 2015


On Wednesday, 30 December 2015 at 20:13:46 UTC, Steven 
Schveighoffer wrote:
> 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

Thanks :)


More information about the Digitalmars-d mailing list