3 ms·
The lookup method explicitly reads uninitialized memory. This is undefined behavior, right? How do you properly implement this method? I guess you should just
by cbarrick 3y ago
The lookup method explicitly reads uninitialized memory.
This is undefined behavior, right?
How do you properly implement this method? I guess you should just initialize it to a sentinel value? But this breaks one of the guarantees presented in the intro...
- hansvm 3y agoSane languages just let you read the memory. If you're using C or something, there are only problems if the compiler can prove the memory is uninitialized (either at comptime or via runtime checks it definitely does not insert). Otherwise, the only reasonable codegen is to return the value at that location in RAM. Just pragma the function doing the dirty work as noinline, and then optimizations can't cross that boundary and mess up your day.