Skip to content

Commit 4160337

Browse files
committed
Tests crash from inappropriate use of common linkage
Normally, variables with common linkage must be zero-initialized. In Rust, common linkage variables that are not zero-initialized causes a crash in the compiler backend. This commit adds a test case to confirm this behavior, which will inform us if it changes in the future.
1 parent 59a8294 commit 4160337

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// build-fail
2+
// failure-status: 101
3+
// known-bug: #109681
4+
5+
// This test verifies that we continue to hit the LLVM error for common linkage with non-zero
6+
// initializers, since it generates invalid LLVM IR.
7+
// Linkages are internal features marked as perma-unstable, so we don't need to fix the issue
8+
// for now.
9+
#![crate_type="lib"]
10+
#![feature(linkage)]
11+
12+
#[linkage = "common"]
13+
#[no_mangle]
14+
pub static TEST: bool = true;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
'common' global must have a zero initializer!
2+
ptr @TEST
3+
LLVM ERROR: Broken module found, compilation aborted!

0 commit comments

Comments
 (0)