Skip to content

Commit d9c2a11

Browse files
committed
compare with C++
1 parent 6c00b70 commit d9c2a11

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

Diff for: rfcs/0000-const-ub.md

+8-2
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,14 @@ While compiling untrusted code should only be done with care (including addition
6464
# Prior art
6565
[prior-art]: #prior-art
6666

67-
TODO: what does C++ constexpr do?
68-
Any other languages we want to compare with?
67+
C++ requires compilers to detect UB in `constexpr`. However, the fragment of C++
68+
that is available to `constexpr` excludes pointer arithmetic and pointer casts,
69+
which makes such checks not very complicated.
70+
71+
If we found a way to run CTFE on unoptimized MIR, then detecting UB for programs that do not use unions, `transmute`, or raw pointers is not very hard.
72+
CTFE already has almost all the checks required for this, except for alignment checks which are disabled during CTFE.
73+
(Disabling them was the easiest way forward to solve some issues around packed structs in patterns, but we could use a different solution and reinstate CTFE alignment checks.
74+
The relevant code paths still exist for Miri.)
6975

7076
# Unresolved questions
7177
[unresolved-questions]: #unresolved-questions

0 commit comments

Comments
 (0)