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

From: Claudio Freire <klaussfreire(at)gmail(dot)com>
To: Xi Wang <xi(dot)wang(at)gmail(dot)com>
Cc: PostgreSQL-Dev <pgsql-hackers(at)postgresql(dot)org>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Subject: Re: [PATCH 1/3] Fix x + y < x overflow checks
Date: 2013-01-24 15:13:53
Message-ID: CAGTBQpabxpp3JMfbeye7nsA0a6-vSw8qnF6M-ezwjPnYeG=G5A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Jan 24, 2013 at 6:36 AM, Xi Wang <xi(dot)wang(at)gmail(dot)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 warning.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Kapila 2013-01-24 15:40:15 Re: Proposal for Allow postgresql.conf values to be changed via SQL [review]
Previous Message Hari Babu 2013-01-24 15:13:50 Re: Passing connection string to pg_basebackup