dmd currently allows casting a string literal with a postfix to any array. It re-interpret casts and creates a StringExp with types and sizes that the frontend can't handle.
```D
auto v0 = cast(float[1]) "abcd"c; // re-interpret casts string bytes to float
auto v1 = cast(ubyte[300][2]) "abcd"c; // assert failure in dcast.d
void main()
{
auto v2 = cast(long[2]) "abcd"c; // assert failure in backend
}
```
Comment #1 by bugzilla — 2024-01-30T20:57:26Z
This should work:
> auto v0 = cast(float[1]) "abcd"c; // re-interpret casts string bytes to float
This should not compile:
> auto v1 = cast(ubyte[300][2]) "abcd"c; // assert failure in dcast.d
This should not compile:
> auto v2 = cast(long[2]) "abcd"c; // assert failure in backend
The rule for array casting is the size of the result should match the size of the operand.
Comment #2 by robert.schadek — 2024-12-13T19:32:55Z