[Issue 14028] New: [CTFE] Possible reinterpret cast to a pointer to static array
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Thu Jan 22 03:06:22 PST 2015
https://issues.dlang.org/show_bug.cgi?id=14028
Issue ID: 14028
Summary: [CTFE] Possible reinterpret cast to a pointer to
static array
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Keywords: CTFE, rejects-valid
Severity: normal
Priority: P1
Component: DMD
Assignee: nobody at puremagic.com
Reporter: k.hara.pg at gmail.com
Following code should work, but doesn't.
int test()
{
int[4] mem;
int[2]* psa;
psa = cast(int[2]*)&mem[1];
(*psa)[0] = 1;
(*psa)[1] = 2;
assert(mem == [0, 1, 2, 0]);
return 1;
}
static assert(test());
Current compiler error:
test.d(6): Error: reinterpreting cast from int[4] to int[2]* is not supported
in CTFE
test.d(9): called from here: test()
test.d(9): while evaluating: static assert(test())
--
More information about the Digitalmars-d-bugs
mailing list