4 ms·
So worth noting that the original code actually exhibits no undefined behavior as written (only q is accessed). I erred in my original argument by looking at th
by jkrejcha 2y ago
So worth noting that the original code actually exhibits no undefined behavior as written (only q is accessed). I erred in my original argument by looking at the "first optimization" being applied.
I'd still argue that the third optimization would be incorrect here, if a program can determine that p+1 = q and replacing q with p+1 is legal, then it obviously knows that those two locations alias (kinda by definition of being able to replace that) and therefore can't apply the 3rd optimization.
- fuhsnn 2y ago>I'd still argue that the third optimization would be incorrect here That's my take as well, to apply it more defensively, any writes cannot be proven in-bounds should be considered clobbering q's state.