You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: text/0000-const-ub.md
+3-3Lines changed: 3 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -23,16 +23,16 @@ There are some values that Rust needs to compute at compile-time.
23
23
This includes the initial value of a `const`/`static`, and array lengths (and more general, const generics).
24
24
Computing these initial values is called compile-time function evaluation (CTFE).
25
25
CTFE in Rust is very powerful and permits running almost arbitrary Rust code.
26
-
This begs the question, what happens when there is `unsafe` code and it causes [Undefined Behavior (UB)][UB]?
26
+
This raises the question, what happens when there is `unsafe` code and it causes [Undefined Behavior (UB)][UB]?
27
27
28
28
The answer depends on the kind of UB: some kinds of UB are guaranteed to be detected,
29
29
while other kinds of UB might either be detected, or else evaluation will continue as if the violated UB condition did not exist (i.e., as if this operation was actually defined).
30
30
This can change from compiler version to compiler version: CTFE code that causes UB could build fine with one compiler and fail to build with another.
31
31
32
32
This RFC does not alter the general policy that unsound code is not subject to strict stability guarantees.
33
33
In other words, unsafe code may not rely on all future versions of Rust to implement this RFC.
34
-
The RFC only helps *consumers* of unsafe code to be sure that right now, all UB during CTFE will be detected or non-consequential.
35
-
It does not grant any new possibilities to *authors* of unsafe code.
34
+
The RFC only helps *consumers* of unsafe code to be sure that right now, all UB during CTFE will be detected or non-consequential (i.e., evaluation will proceed as if there was no UB).
35
+
It does not grant any new possibilities to *authors* of unsafe code; in particular, it is still considered a critical bug for CTFE code to raise UB, and no stability guarantees are made for such code (as is the case with regular runtime code raising UB).
0 commit comments