On Fri, 27 Sept 2024 at 12:28, Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx> wrote: > > Dammit, people, read the code I posted. Actually, no, apologies. You were right, and I was wrong. It does need both of the sources of the comparison to be hidden, because while even hiding just one side makes the comparison result "meaningless" as far as the compiler is concerned, the compiler will still have generated a pseudo for the hidden value, and might decide that it can re-use that pseudo for the non-hidden pointer if the two then match. So yeah, the example function I posted should be safe, but my "you can probably make do with hiding just one side" was actually a bogus and invalid optimization. You do need to hide both sides. Not just for clarity, but for correctness. Linus