3 ms·
safety-checked UB; an important distinction. I assume.
by naikrovek 4y ago
safety-checked UB; an important distinction. I assume.
- planede 4y agoNot very. It really just means that "there is a sanitized mode for building", which already exists in many C and C++ compilers (for language UB) and standard libraries (for library UB).
- naikrovek 4y agoI think of this case as an assert() that both lists are the same length. if they're not, I want to know about that via a crash.
- oconnor663 4y agoI think Zig's ReleaseSafe mode is intended to be suitable for production, which IIUC isn't really the case with ASan, UBSan, and friends. Those have some performance problems and also some attack surface problems.
- planede 4y agoOK, but is "safe" in ReleaseSafe any kind of guarantee, or is it just safer than ReleaseFast? I can enable lightweight assertions in libstdc++ and libc++ and it makes C++ safer, but not in any way "safe". There are some flags that can be enabled to trap on some language UB too, without bringing in the heavy weight sanitizers.
- oconnor663 4y agoLast time I checked (more than a year ago) there were major open questions about what could be guaranteed. My impression was that you could expect e.g. all array accesses to be bounds checked, but that use-after-free and dangling pointers were still issues, especially if you use the C allocator.
- Yoric 4y agoCould you elaborate? What's a safety-checked UB?
- codethief 4y agohttps://ziglang.org/documentation/master/#Undefined-Behavior https://ziglang.org/documentation/master/#Undefined-Behavior
- Yoric 4y agoThanks. So, if I read this correctly, barring the simple cases that Zig can detect at compile-time, this means that whether it's a UB (in the C++ definition of the term) depends on the flags specified by the author of the library and the person who compiles the final binary. That's definitely much better than C++ UB. Still a bit scary, though.
- deleted 4y ago[deleted]