comment this line because its causing gcc warnings (didn't even know that gcc is
that smart ! - smarter than it should) - but in the end its right:

  if (top > curbuf->b_ml.ml_line_count
      || top >= bot
      || bot > curbuf->b_ml.ml_line_count + 1)

Let's rewrite:

  if ( top > N  // 1
      || top >= bot // 2
      || N + 1 < bot) // 3

  If 1 is not true, then we know top <= N, adding line 3 we get:

  Now  top <= N < N + 1 < bot

  Thus top <= bot, thus line 2 will never be true, thus it can be
  dropped. Thanks to roxfan @ #gcc to help me understand this.
  gcc 4.7's error message is still very strange:

    src/undo.c:253:7: error: assuming signed overflow does not occur when assuming that (X - c) > X is always false [-Werror=strict-overflow]
       || top >= bot
       ^
    cc1: all warnings being treated as errors