Linus Torvalds writes: (Summary) If clang
actually did proper optimization, it would have noticed that the
"offset backwards" was followed by an "offset forwards" and then a
NULL pointer check, and that there actually was no actual real
wrapping or non-contiguous behavior in reality.
wrapping or non-contiguous behavior in reality.
But clang didn't do that, and instead blindly said "you're going forwards and the result can't be NULL", without ever looking at "oh, they went backwards first".
they went backwards first".
So honestly, part of the problem we had with clang was that it was too *stupid* to see that what we did wasn't actually invalid even by clang's own standards!
clang's own standards!
I'm not saying that the kernel use is really standards compliant, because there definitely are those temporary pointer values (that are never used!) that point outside an object.
never used!) that point outside an object.
But honestly, the clang "optimization" is really quite debatable, and we'd want to turn i
wrapping or non-contiguous behavior in reality.
But clang didn't do that, and instead blindly said "you're going forwards and the result can't be NULL", without ever looking at "oh, they went backwards first".
they went backwards first".
So honestly, part of the problem we had with clang was that it was too *stupid* to see that what we did wasn't actually invalid even by clang's own standards!
clang's own standards!
I'm not saying that the kernel use is really standards compliant, because there definitely are those temporary pointer values (that are never used!) that point outside an object.
never used!) that point outside an object.
But honestly, the clang "optimization" is really quite debatable, and we'd want to turn i