[Issue 293] New: Expression uint.max + 1 yields 0 (zero)
BCS
BCS at pathlink.com
Thu Aug 17 08:55:47 PDT 2006
Oskar Linde wrote:
> d-bugmail at puremagic.com wrote:
>
>> http://d.puremagic.com/issues/show_bug.cgi?id=293
>>
>> Summary: Expression uint.max + 1 yields 0 (zero)
>> Product: D
>> Version: 0.164
>> Platform: PC
>> OS/Version: Linux
>> Status: NEW
>> Severity: normal
>> Priority: P2
>> Component: DMD
>> AssignedTo: bugzilla at digitalmars.com
>> ReportedBy: m.faustino at gmail.com
>>
>>
>> The expression uint.max + 1, yields 0 (zero). For example, the
>> following code
>> will print "4294967296 == 0":
>>
>> //----------------------------------------------------------
>> import std.stdio;
>>
>> void main()
>> {
>> ulong u = uint.max;
>> writefln(u + 1, " == ", uint.max + 1);
>>
>> }
>> //----------------------------------------------------------
>
>
> This is not a bug. Look under Integer Promotions on
> http://www.digitalmars.com/d/type.html
>
> type type of (uint) + (int) is (uint), not (ulong)
>
> /Oskar
Shouldn't the bug be the overflow in the constant folding? I would hope
that the DMD would error on overflows in constant expressions.
More information about the Digitalmars-d-bugs
mailing list