18 Jun
2012
18 Jun
'12
2:29 p.m.
On Sat, Jun 16, 2012 at 01:31:01AM +0400, 123 wrote:
In function Cache_client_enqueue variable ClientKey is incremented and checked for negative values after that (in case of overflow).
Even though overflow is unlikely, signed integer overflow results in wraparound on most systems and gcc don't seem to optimize away overflow check even with -O3 (it only inlines Cache_client_enqueue in my case) it is better to avoid overflow completely as there are other compilers and compiler versions.
+1. Agreed. I'd add a comment to remember this. e.g. /* integer wraparound/overflow is not defined by C/C++ standards */ -- Cheers Jorge.-