|
|
|
|
|
by AlotOfReading
840 days ago
|
|
I wrote up a quick example demonstrating UB compiling to two different implementations:
https://godbolt.org/z/nd7GrP44s Ignore how silly the actual code is and notice that the -O0 assembly checks the pointers before dereferencing them while the -O2 assembly does not. Same compiler, same translation unit, different assembly. Calling each with null pointers will behave differently too. Run this with whatever reproducible toolchain you want. Reproducible builds are not about making undefined behavior deterministic, they're a separate and largely unrelated topic. |
|