[Issue 24361] New: casting string literal to static int array is broken

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Jan 29 16:35:45 UTC 2024


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

          Issue ID: 24361
           Summary: casting string literal to static int array is broken
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Keywords: ice
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: dkorpel at live.nl

Found by Iain Buclaw:

```
void main()
{
    ubyte[1] w = cast(ubyte[1]) "A"; // Passes
    uint[1] x = cast(uint[1]) "\xFF\xAA\xDD\xEE";
    ulong[2] y = cast(ulong[2])
"\x11\x22\x33\x44\x55\x66\x77\x88\xAA\xBB\xCC\xDD\xEE\xFF\x00\x99";
}
```

These should be semantic errors, not backend errors.
```
Error: e2ir: cannot cast `"\xff\xaa\xdd\xee"` of type `string` to type
`uint[1]`
Error: e2ir: cannot cast `"\x11\"3DUfw\x88\xaa\xbb\xcc\xdd\xee\xff\0\x99"` of
type `string` to type `ulong[2]`
```

--


More information about the Digitalmars-d-bugs mailing list