www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 8929] New: long.min is a Voldermort literal

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8929

           Summary: long.min is a Voldermort literal
           Product: D
           Version: D1 & D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: david.eckardt sociomantic.com



09:23:21 PDT ---
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

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 01 2012
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8929


monarchdodra gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |monarchdodra gmail.com




 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: -------
Nov 01 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8929


Don <clugdbug yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|long.min is a Voldermort    |long.min is a Voldemort
                   |literal                     |literal





 It cannot be named.
 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:
Yes, of course that's what's happening. It is a number you cannot write as a literal, you can only use a euphemism like "long.min" or "-2L^^63". -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Nov 02 2012
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8929




05:16:23 PDT ---
Although no surprise, it might be worth noting that

mixin("static assert(long.min==" ~ long.min.stringof ~ ");");

causes the "signed integer overflow" error, too.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 02 2012