[Issue 8929] long.min is a Voldermort literal
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Nov 1 14:27:11 PDT 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8929
monarchdodra at gmail.com changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |monarchdodra at gmail.com
--- Comment #1 from monarchdodra at gmail.com 2012-11-01 14:27:09 PDT ---
(In reply to comment #0)
> It cannot be named.
>
> static assert (long.min == -9223372036854775807L);
> // Error: static assert (-9223372036854775808L == -9223372036854775807L) is
> false
>
> static assert (long.min == -9223372036854775808L);
> // Error: signed integer overflow
I don't think this has anything to do with voldermort, and this works just
fine:
void main()
{
long a = -2L^^63;
assert(a == long.min);
long b = long.min;
assert(b == long.min);
}
It sounds more like an interpretation error, whereas *writing*
"-9223372036854775808L;" causes an error.
My *guess* is interprets the decimal number into a long, and afterwards, the
sign is applied. This chokes in this particular case, because the valid range
for longs is [-2^^63, 2^^63-1], so the interpreted number overflows before the
compiler has a chance to apply the sign:
long a = 9223372036854775808L; //WRONG
long b = -9223372036854775808L; //LEGAL
But that's just speculation on my part.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list