www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 24362] New: casting a string literal with a postfix to array

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 puremagic.com
          Reporter: dkorpel 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
}
```

--
Jan 30