
Dear Michael,
In message CAPx6ZwHLn-VABzQOyAMF+T2VyQEc3MZDi1E_kdTVZG8OkJmBYA@mail.gmail.com you wrote:
it's possible that these checks could be simply optimised away. The
This is not hwat happens.
Actually, it is my understanding that the "if (p + len < p)" can be optimized away. This exact case is discussed in the LWN article "GCC and pointer overflows"[1].
No, this does not apply here. You miss a key point. We are not doing any pointer arithmetics here. We have:
int offset; unsigned int len;
and then do:
if (((offset + len) < offset) ...) ...
Basically, the C standard states that pointer arithmetic should not cause overflow, thus allowing the compiler to assume that "p + len" must always be greater than "p".
This is totally irrelevant here. There are no pointers being used here.
--001a1133769056575204e93035f1 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Can you please stop posting HTML? Thanks!
Best regards,
Wolfgang Denk