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

          Issue ID: 14582
           Summary: bigEndianToNative buffer slice allows only literals
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: regression
          Priority: P1
         Component: DMD
          Assignee: [email protected]
          Reporter: [email protected]

The std.batmanip bigEndianToNative has a regression where the 
slice range doesn't work with variables (only literals).

Using this main.d:
import std.bitmanip;
int main(string args[])
{
   auto datain = new ubyte[16];

   // this syntax works
   ushort descriptorLength = 
bigEndianToNative!ushort(datain[2..4]);

   // this syntax fails (worked in previous version)
   int offset = 2;
   descriptorLength = bigEndianToNative!ushort(cast(ubyte[2]) 
datain[offset..offset+2]);

   return 0;
}


I get this error on the command line:
main.d(14): Error: cannot cast expression
datain[cast(uint)offset..cast(uint)(offset + 2)] of type ubyte[] to ubyte[2]

--

Reply via email to