Summary: array casts behave differently at compile and runtime
           Product: D
           Version: 1.037
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Keywords: spec
          Severity: normal
          Priority: P2
         Component: DMD

This is related to casts of arrays not being documented:

The issue is that the following produce different results:

const short[] ct = cast(short[]) [cast(byte)1, 1]; // ct is [1, 1]
short[] rt = cast(short[]) [cast(byte)1, 1].dup; // rt is [ 257 ]

The runtime cast seems to be defined as 'reinterpret the data as an array of a
different type, recompute the length' whereas the compile time cast seems to be
'convert each element to the other element type, keep length unchanged'.


Reply via email to