count = count + i
is just before overflowing. In that case the O(N) algorithm has no overflow, but if you look at the closed form solution. Surely
(count)*(count-1)
would overflow.
A compiler must never be allowed to swap a non-overflow with a overflow. Which is one big limit of these optimizations.
count = count + i
is just before overflowing. In that case the O(N) algorithm has no overflow, but if you look at the closed form solution. Surely
(count)*(count-1)
would overflow.
A compiler must never be allowed to swap a non-overflow with a overflow. Which is one big limit of these optimizations.