Skip to content

Commit fc53654

Browse files
committed
Add reference to Rust issue 46188
There's a long history of discussion on how incorrect declarations in `extern` blocks might cause UB in programs compiled using LLVM. Let's link to one of the issues in that history. (Thanks to madsmtm for raising this question, and to RalfJ for providing this citation.)
1 parent 60631ce commit fc53654

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

text/0000-unsafe-extern-blocks.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,13 @@ In Edition 2024 it is `unsafe` to declare an `extern` function or static, but ex
1111
# Motivation
1212
[motivation]: #motivation
1313

14-
Simply declaring extern items, even without ever using them, can cause Undefined Behavior.
14+
Simply declaring extern items, even without ever using them, can cause Undefined Behavior (see, e.g., issue [#46188][]).
1515
When performing cross-language compilation, attributes on one function declaration can flow to the foreign declaration elsewhere within LLVM and cause a miscompilation.
1616
In Rust we consider all sources of Undefined Behavior to be `unsafe`, and so we must make declaring extern blocks be `unsafe`.
1717
The up-side to this change is that in the new style it will be possible to declare an extern fn that's safe to call after the initial unsafe declaration.
1818

19+
[#46188]: https://github.com/rust-lang/rust/issues/46188
20+
1921
# Guide-level explanation
2022
[guide-level-explanation]: #guide-level-explanation
2123

0 commit comments

Comments
 (0)