Daniel Dunbar | a572887 | 2009-12-15 20:14:24 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -emit-llvm -o - %s |
Daniel Dunbar | 9986eab | 2008-07-30 16:32:24 +0000 | [diff] [blame] | 2 | // <rdar://problem/6108358> |
| 3 | |
| 4 | /* For posterity, the issue here begins initial "char []" decl for |
| 5 | * s. This is a tentative definition and so a global was being |
| 6 | * emitted, however the mapping in GlobalDeclMap referred to a bitcast |
| 7 | * of this global. |
| 8 | * |
| 9 | * The problem was that later when the correct definition for s is |
| 10 | * emitted we were doing a RAUW on the old global which was destroying |
| 11 | * the bitcast in the GlobalDeclMap (since it cannot be replaced |
| 12 | * properly), leaving a dangling pointer. |
| 13 | * |
| 14 | * The purpose of bar is just to trigger a use of the old decl |
| 15 | * sometime after the dangling pointer has been introduced. |
| 16 | */ |
| 17 | |
| 18 | char s[]; |
| 19 | |
| 20 | static void bar(void *db) { |
| 21 | eek(s); |
| 22 | } |
| 23 | |
| 24 | char s[5] = "hi"; |
| 25 | |
| 26 | int foo() { |
| 27 | bar(0); |
| 28 | } |