Problems with shift left operator (dmd 0.169)

KlausO oberhofer at users.sourceforge.net
Tue Oct 10 23:17:17 PDT 2006


Hello D-experts,

I created a little test program which IMHO shows
not the expected behaviour.
Is this a bug or not ?

module testshift;

import std.stdio;

void main()
{
   uint val_a = (1 << 32);

   uint shift = 32;
   uint val_b = (1 << shift);

   writefln("Result: ", val_a, "  ", val_b);
   assert(val_a == val_b);
}

Output is as follows:
Result: 0  1
Error: AssertError Failure testshift(14)



More information about the Digitalmars-d-learn mailing list