Re: [PATCH 0/3] Work around icc miscompilation

From: Xi Wang <xi(dot)wang(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Greg Stark <stark(at)mit(dot)edu>, Heikki Linnakangas <hlinnakangas(at)vmware(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: [PATCH 0/3] Work around icc miscompilation
Date: 2013-02-23 17:39:21
Message-ID: CAKU6vyZ9NnVdB46xtxWFYWHg2Syt+59fsA7+aCeXfTsP_uki6Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

It depends on the context. In the patches, `a' is known to be
non-negative, so `INT_MAX - a' cannot overflow. If you ignore the
context and talk about the general case, then it can.

- xi

On Sat, Feb 23, 2013 at 12:25 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Greg Stark <stark(at)mit(dot)edu> writes:
>> He's changing things to do
>
>> if (INT_MAX - a > b)
>> PG_THROW ("a+b would overflow")
>> else
>> x=a+b;
>
>> Why would a smarter compiler be licensed to conclude that it can
>> optimize away anything? "INT_MAX-a > b" is always well defined.
>
> Really? Can't "INT_MAX - a" overflow?
>
> regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrew Dunstan 2013-02-23 17:39:57 Re: make: *** pg_xlogdump: No such file or directory. Stop.
Previous Message Tom Lane 2013-02-23 17:25:52 Re: [PATCH 0/3] Work around icc miscompilation