[Issue 24362] New: casting a string literal with a postfix to array re-interpret casts anything

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Jan 30 13:08:00 UTC 2024


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

          Issue ID: 24362
           Summary: casting a string literal with a postfix to array
                    re-interpret casts anything
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Keywords: ice
          Severity: major
          Priority: P3
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: dkorpel at live.nl

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
}
```

--


More information about the Digitalmars-d-bugs mailing list