[Issue 4491] New: Assigning large const value to ulong type results in "signed integer overflow"

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Jul 21 13:50:23 PDT 2010


http://d.puremagic.com/issues/show_bug.cgi?id=4491

           Summary: Assigning large const value to ulong type results in
                    "signed integer overflow"
           Product: D
           Version: D1 & D2
          Platform: x86
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: ibuclaw at ubuntu.com


--- Comment #0 from Iain Buclaw <ibuclaw at ubuntu.com> 2010-07-21 13:50:16 PDT ---
The following code:

import std.stdio;
void main()
{
    ulong t;// = 18446744073709551615;
    printf("%llu\n", t.max);
}


Outputs:
18446744073709551615

However, I get a "signed integer overflow" when I try to assign the value
directly.

Code:
import std.stdio;
void main()
{
    ulong t = 18446744073709551615;
    printf("%llu\n", t);
}

Outputs:
bug.d(4): signed integer overflow

Using 'cast(ulong)18446744073709551615' doesn't help either, so I presume this
happens before D knows what datatype the large integer will be assigned to.

IMO, assignments of constant values within the range of foo.min to foo.max
should be allowed for all types.

-- 
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