Infamous (not much known) gcc bug
According to CERT C Coding Standard when you face to integer overflow you should use -ftrapv
gcc flag. And everything should be fine.
Really should because it does not work. Wheee.
I was curious. Why this nice feature does not work? I decided to do small analyse of a bug. And here it is.
Looks like bug is known from 2008 - link and patches are finally here.