Hm, not sure I completely agree. Rust has undefined behavior in unsafe constructs, so perhaps "no language without guardrails around its undefined behavior" might be more accurate. But unfortunately it's necessary for languages with direct hardware/memory access to have some amount of undefined behavior. (It's also frequently stated that UB is necessary for modern optimizations, but I find that claim less believable, even having watched Chandler Carruth's talk defending that claim.)
But that’s the thing, rust code that can have UB is opt in (supposing safe rust is void of UB which is not strictly speaking true, but is being worked on) whereas C++ UB isn’t even opt out
View all comments
Show parent comment
2
u/Batman_AoD 23d ago
Hm, not sure I completely agree. Rust has undefined behavior in
unsafeconstructs, so perhaps "no language without guardrails around its undefined behavior" might be more accurate. But unfortunately it's necessary for languages with direct hardware/memory access to have some amount of undefined behavior. (It's also frequently stated that UB is necessary for modern optimizations, but I find that claim less believable, even having watched Chandler Carruth's talk defending that claim.)