Re: [HACKERS] [PATCH 1/3] Fix x + y x overflow checks

2013-01-25 Thread Robert Haas
On Thu, Jan 24, 2013 at 4:36 AM, Xi Wang xi.w...@gmail.com wrote: icc optimizes away the overflow check x + y x (y 0), because signed integer overflow is undefined behavior in C. Instead, use a safe precondition test x INT_MAX - y. As you post these patches, please add them to:

[HACKERS] [PATCH 1/3] Fix x + y x overflow checks

2013-01-24 Thread Xi Wang
icc optimizes away the overflow check x + y x (y 0), because signed integer overflow is undefined behavior in C. Instead, use a safe precondition test x INT_MAX - y. --- src/backend/utils/adt/varbit.c |7 +-- src/backend/utils/adt/varlena.c | 10 ++

Re: [HACKERS] [PATCH 1/3] Fix x + y x overflow checks

2013-01-24 Thread Claudio Freire
On Thu, Jan 24, 2013 at 6:36 AM, Xi Wang xi.w...@gmail.com wrote: icc optimizes away the overflow check x + y x (y 0), because signed integer overflow is undefined behavior in C. Instead, use a safe precondition test x INT_MAX - y. I should mention gcc 4.7 does the same, and it emits a