[Issue 2542] New: array casts behave differently at compile and runtime
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Dec 26 09:20:00 PST 2008
http://d.puremagic.com/issues/show_bug.cgi?id=2542
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
AssignedTo: bugzilla at digitalmars.com
ReportedBy: kamm-removethis at incasoftware.de
This is related to casts of arrays not being documented:
http://d.puremagic.com/issues/show_bug.cgi?id=2494
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'.
--
More information about the Digitalmars-d-bugs
mailing list