| 1 |
/* |
| 2 |
TEST_OUTPUT: |
| 3 |
--- |
| 4 |
fail_compilation/reg6769.d(14): Error: reinterpreting cast from `int[]` to `int[7]*` is not supported in CTFE |
| 5 |
fail_compilation/reg6769.d(27): called from here: `reg6769a([0, 1, 2, 3, 4, 5, 6])` |
| 6 |
fail_compilation/reg6769.d(27): while evaluating: `static assert(reg6769a([0, 1, 2, 3, 4, 5, 6]) == 1)` |
| 7 |
fail_compilation/reg6769.d(20): Error: reinterpreting cast from `int[7]` to `int[]*` is not supported in CTFE |
| 8 |
fail_compilation/reg6769.d(28): called from here: `reg6769b([0, 1, 2, 3, 4, 5, 6])` |
| 9 |
fail_compilation/reg6769.d(28): while evaluating: `static assert(reg6769b([0, 1, 2, 3, 4, 5, 6]) == 1)` |
| 10 |
--- |
| 11 |
*/ |
| 12 |
int reg6769a(int[] a) |
| 13 |
{ |
| 14 |
int[7]* b = cast(int[7]*)&a; |
| 15 |
return (*b)[1]; |
| 16 |
} |
| 17 |
|
| 18 |
int reg6769b(int[7] a) |
| 19 |
{ |
| 20 |
int[]* b = cast(int[]*)&a; |
| 21 |
return (*b)[1]; |
| 22 |
} |
| 23 |
|
| 24 |
void main() |
| 25 |
{ |
| 26 |
// Both should never succeed, run-time would raise a SEGV. |
| 27 |
static assert(reg6769a([0,1,2,3,4,5,6]) == 1); |
| 28 |
static assert(reg6769b([0,1,2,3,4,5,6]) == 1); |
| 29 |
} |