From 059cf1450ce113392667a3ab7c48d620a4574db3 Mon Sep 17 00:00:00 2001 From: David Nadlinger Date: Sun, 5 May 2013 15:49:42 +0200 Subject: [PATCH] Remove undefined behavior from test23. The code tried to load 4 bytes from an 1-3 byte allocation. LLVM's optimizer actually detects this, marking the entire result undefined. --- test/runnable/test23.d | 24 ++---------------------- 1 file changed, 2 insertions(+), 22 deletions(-) diff --git a/test/runnable/test23.d b/test/runnable/test23.d index c2d959b09e44..257aba2e2148 100644 --- a/test/runnable/test23.d +++ b/test/runnable/test23.d @@ -1336,28 +1336,8 @@ void test64() void test65() { - int i; - char[1] c = ['0']; - i = c[0]; // ok - i = *cast(int*)c; // ok - assert((i & 0xFF) == 0x30); - - i = *cast(int*)['0']; // compiler seg-fault - assert((i & 0xFF) == 0x30); - - if (0) - i = *cast(int*)cast(char[0])[]; // compiler seg-fault - i = *cast(int*)cast(char[1])['0']; // compiler seg-fault - i = *cast(int*)cast(char[1])"0"; // ok - -// i = *cast(int*)cast(char[3])['0']; // ok -// i = *cast(int*)cast(char[3])['0', '0']; // ok - i = *cast(int*)cast(char[3])['0', '0', '0']; // compiler seg-fault - -// i = *cast(int*)cast(char[4])['0', '0', '0']; // ok - i = *cast(int*)cast(char[4])['0', '0', '0', '0']; // compiler seg-fault - - i = *cast(int*)cast(char[])['0','0','0']; // ok + // Bugzilla Issue 407. + int i = *cast(int*)cast(char[4])['0', '0', '0', '0']; // compiler seg-fault printf("i = %x\n", i); }