Branch: Tag:

2021-09-15

2021-09-15 16:09:55 by Marcus Comstedt <marcus@mc.pp.se>

Compiler [Typechecker]: Workaround for gcc optimization of signed overflow

The expression "(min1 > max2) && (min1 > max2 + 1)" got optimized into
"(min1 > max2 + 1)" by gcc, because of min1 is larger than max2 + 1,
then it clearly must be larger than max2 as well... Except when max2 + 1
is a signed overflow. So explicitly check for that instead and hope gcc
doesn't optimize away that check as well...

3424:    }    }    -  if ((min1 > max2) && (min1 > max2 + 1)) { +  if ((max2 < MAX_INT32) && (min1 > max2 + 1)) {    /* No overlap. */    push_finished_type(t);   #ifdef PIKE_DEBUG -  } else if ((min2 > max1) && (min2 > max1 + 1)) { +  } else if ((max1 < MAX_INT32) && (min2 > max1 + 1)) {    /* No overlap and wrong order! */    Pike_fatal("Bad integer ordering in lower_or_pike_types().\n");   #endif