www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 14582] New: bigEndianToNative buffer slice allows only literals


          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: nobody puremagic.com
          Reporter: ljdelight gmail.com

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 = 

   // this syntax fails (worked in previous version)
   int offset = 2;
   descriptorLength = bigEndianToNative!ushort(cast(ubyte[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]

May 13 2015