2 // compile-flags: --crate-type=rlib --emit=llvm-ir -Cno-prepopulate-passes
4 // This test declares globals by the same name with different types, which
5 // caused problems because Module::getOrInsertGlobal would return a Constant*
6 // bitcast instead of a GlobalVariable* that could access linkage/visibility.
7 // In alt builds with LLVM assertions this would fail:
9 // rustc: /checkout/src/llvm-project/llvm/include/llvm/Support/Casting.h:269:
10 // typename cast_retty<X, Y *>::ret_type llvm::cast(Y *) [X = llvm::GlobalValue, Y = llvm::Value]:
11 // Assertion `isa<X>(Val) && "cast<Ty>() argument of incompatible type!"' failed.
13 // In regular builds, the bad cast was UB, like "Invalid LLVMRustVisibility value!"
17 pub static GLOBAL1: [u8; 1] = [1];
22 pub static GLOBAL1: u8;
23 pub static GLOBAL2: u8;
27 drop(unsafe { (GLOBAL1, GLOBAL2) });
33 pub static GLOBAL2: [u8; 1] = [2];