strange pointer casting (64 bit)
Simon Buerger
krox at gmx.net
Sun Jun 29 08:30:06 PDT 2008
hi
From my point of view, the following piece of code does really
strange thing:
write("{}", cast(void*)0xFFFF_FFFF_FFFF_FFFF_UL); // prints
ffffffffffff, OK
write(cast(ulong*)0xFFFF_FFFF_FFFF_FFFF_UL); // prints ffffffffffff, OK
write("{}", cast(ulong*)cast(void*)0xFFFF_FFFF_FFFF_FFFF_UL); //
prints ffffffff, not OK
Its not a question of output routine, I've checked it in different
envirovments and with different values. It simply cuts of the higher
32 bit part of the address. Could, please, somebody explain me that
behavior? For me, it looks like a compiler bug, but that seems
impossible for such an obvious thing...
my system:
AMD64, Ubuntu Linux,
gdc (GCC) 4.1.2 20070214 ( gdc 0.24, using dmd 1.024)
(according to gdc --version)
More information about the D.gnu
mailing list