www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Is this a bug?

reply Jordi Sayol <g.sayol yahoo.es> writes:
Hello,

When compiling next code to 64-bit.

app.d
----
import std.stdio;

void main()
{
	ubyte u1 = cast(byte)-1;
	byte u2 = cast(short)-1;
	uint u3 = cast(int)-1;
	int u4 = cast(long)-1;
	writefln("%d", u1);
	writefln("%d", u2);
	writefln("%d", u3);
	writefln("%d\n", u4);

	writefln("long.sizeof: %d  ulong.max: %20d", ulong.sizeof, ulong.max);
	writefln("long.sizeof: %d   long max: %20d", long.sizeof, long.max);
}
----

Prints this:
----
255
-1
4294967295
-1

long.sizeof: 8  ulong.max:           4294967295
long.sizeof: 8   long max:  9223372036854775807
----

"ulong.max" value is incorrect

Tested with dmd version 2.056, 2.057, 2.058, 2.059, 2.060 and 2.061 

No problem when compiling to 32-bit.

-- 
Jordi Sayol
Jan 15 2013
parent "David Nadlinger" <see klickverbot.at> writes:
Yes, this seems to be a DMD codegen bug – works with LDC.

David
Jan 16 2013