digitalmars.D.bugs - [Issue 14028] New: [CTFE] Possible reinterpret cast to a pointer to
- via Digitalmars-d-bugs (33/33) Jan 22 2015 https://issues.dlang.org/show_bug.cgi?id=14028
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 puremagic.com Reporter: k.hara.pg 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()) --
Jan 22 2015