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]
Broken by https://github.com/D-Programming-Language/dmd/pull/4193. I believe this change is intentional.
(In reply to Vladimir Panteleev from comment #1) > Broken by https://github.com/D-Programming-Language/dmd/pull/4193. > > I believe this change is intentional. Yes, this is intentional change, so it's not a regression. To support such the cast operation (from a dynamic array slice with offset + compile-time known length to static array reference), I'm proposing enhancement issue 13700, but my compiler change for that is not yet merged.