icc optimizes away x + 1 < x because signed integer overflow is
undefined behavior in C. Instead, simply check if x is INT_MAX.
---src/backend/utils/adt/float.c | 8 ++++----1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/backend/utils/adt/float.c b/src/backend/utils/adt/float.c
index b73e0d5..344b092 100644
--- a/src/backend/utils/adt/float.c
+++ b/src/backend/utils/adt/float.c
@@ -2764,12 +2764,12 @@ width_bucket_float8(PG_FUNCTION_ARGS) result = 0; else if (operand >= bound2)
{
- result = count + 1; /* check for overflow */
- if (result < count)
+ if (count == INT_MAX) ereport(ERROR,
(errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE), errmsg("integer out of range")));
+ result = count + 1; } else result = ((float8) count * (operand - bound1) /
(bound2- bound1)) + 1;
@@ -2780,12 +2780,12 @@ width_bucket_float8(PG_FUNCTION_ARGS) result = 0; else if (operand <= bound2)
{
- result = count + 1; /* check for overflow */
- if (result < count)
+ if (count == INT_MAX) ereport(ERROR,
(errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE), errmsg("integer out of range")));
+ result = count + 1; } else result = ((float8) count * (bound1 - operand) /
(bound1- bound2)) + 1;
--
1.7.10.4