https://issues.dlang.org/show_bug.cgi?id=22055
Issue ID: 22055
Summary: [The D Bug Tracker] Casting slices in CTFE yields the
wrong result
Product: D
Version: D2
Hardware: All
URL: http://dlang.org/
OS: All
Status: NEW
Severity: major
Priority: P3
Component: dmd
Assignee: [email protected]
Reporter: [email protected]
unittest {
int[] runtimeInts = [1,2];
enum int[] compiletimeInts = [1,2];
pragma(msg, "pragma(msg): ", cast(ubyte[])compiletimeInts);
writefln("CT: %s", cast(ubyte[])compiletimeInts);
writefln("RT: %s", cast(ubyte[])runtimeInts);
}
Outputs:
pragma(msg): [cast(ubyte)1u, cast(ubyte)2u]
CT: [1, 2]
RT: [1, 0, 0, 0, 2, 0, 0, 0]
This is a problematic semantic discrepancy between compile-time and runtime,
and even between 2 runtime values if they're casts of compile-time vs. runtime
values.
I suppose the runtime value is the correct one.
--