UB in Rust vs C
UB in Rust vs C
Posted Aug 14, 2024 21:11 UTC (Wed) by abatters (✭ supporter ✭, #6932)In reply to: UB in Rust vs C by ralfj
Parent article: Standards for use of unsafe Rust in the kernel
Compilers have flags such as -fwrapv to turn some UB into well-defined behavior, in which case it should be safe to rely on the flag to do what it is supposed to do. For example, the kernel Makefile has:
KBUILD_CFLAGS += -fno-strict-aliasing
# disable invalid "can't wrap" optimizations for signed / pointers
KBUILD_CFLAGS += -fno-strict-overflow
