[Issue 8901] a bug to cast from array literal to ubyte[]
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Feb 8 17:20:43 UTC 2023
https://issues.dlang.org/show_bug.cgi?id=8901
Ate Eskola <Ajieskola at gmail.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |REOPENED
CC| |Ajieskola at gmail.com
Resolution|INVALID |---
--- Comment #6 from Ate Eskola <Ajieskola at gmail.com> ---
I was just bitten by this one. Test case:
------------------
void main()
{ import std.stdio;
// Excepted: 1 on big endian machine, 0 on little endian machine
// Got: Error: array index 3 is out of bounds `[cast(ubyte)1u][0 .. 1]
(cast(ubyte[]) [1])[3].writeln();
}
------------------
Maybe this is behaving as intended, but if so, I'm unable to find the spec rule
that says so. Instead https://dlang.org/spec/expression.html#array_literals
says that array literals are dynamic arrays of common type of their element.
Reopening until the spec and implementation match.
--
More information about the Digitalmars-d-bugs
mailing list