www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 24879] New: Weird bug...

https://issues.dlang.org/show_bug.cgi?id=24879

          Issue ID: 24879
           Summary: Weird bug...
           Product: D
           Version: D2
          Hardware: All
               URL: http://dlang.org/
                OS: All
            Status: NEW
          Severity: normal
          Priority: P3
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: turkeyman gmail.com

ubyte[8] bytes = [0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, 0xDE, 0xF0];

ulong ii = cast(ulong)bytes[0] << 56 | cast(ulong)bytes[1] << 48 |
cast(ulong)bytes[2] << 40 | cast(ulong)bytes[3] << 32;
ulong i = ii | bytes[4] << 24 | bytes[5] << 16 | bytes[6] << 8 | bytes[7];

assert(ii == 0x1234567800000000); // this is correct
assert(i == 0x123456789abcdef0);  // but this results in 0xFFFFFFFF9abcdef0

Weird!

--
Nov 25