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