Open andrewrk opened 8 years ago
Related: #1966
After solving #1947, this issue will be for implementing runtime safety for undefined behavior caused by any of the reasons listed in #1947.
LLVM has a MemorySanitizer that can detect uninitialized reads with supposedly only 2-3x slowdown compared to 20-30x under valgrind. It has quite a few limitations however: https://clang.llvm.org/docs/MemorySanitizer.html
There's a paper on the implementation titled "MemorySanitizer: fast detector of uninitialized memory use in C++" which looks to be valuable reading for anyone looking into this kind of runtime safety check for zig: https://static.googleusercontent.com/media/research.google.com/en//pubs/archive/43308.pdf
Additional drawback as mentioned in https://github.com/ziglang/zig/issues/2301#issuecomment-838000424:
With this approach for checking UUM => 2.5x compiletime cost, 2x memory. However, this approach still includes false negatives (there can be UUM even though the check says there is none).
expected output: the runtime calls
@panic("branch on undefined value")