My questions are divided into three parts
Question 1
Consider the below code,
#include
using namespace std;
i
It's a known problem, and I don't think it's considered a bug in the compiler. When I compile with gcc 4.5 with -Wall -O2
it warns
warning: assuming signed overflow does not occur when assuming that (X + c) < X is always false
Although your code does overflow.
You can pass the -fno-strict-overflow
flag to turn that particular optimization off.