Re: BUG #15519: Casting float4 into int4 gets the wrong sign instead of "integer out of range" error

Tom Lane <tgl@sss.pgh.pa.us>

From: Tom Lane <tgl@sss.pgh.pa.us>
To: Andrew Gierth <andrew@tao11.riddles.org.uk>
Cc: victor@magic.io, pgsql-bugs@lists.postgresql.org
Date: 2018-11-23T23:58:14Z
Lists: pgsql-bugs
I wrote:
> Andrew Gierth <andrew@tao11.riddles.org.uk> writes:
>> if (num < (float4)INT_MIN || num >= -(float4)INT_MIN || ...

> Meh.  Seems to me that's relying on pretty much the same assumptions
> and throwing in an extra dollop of obscurantism on top.

mmm ... but on the other hand, it means we don't need to write the
test differently depending on whether we think INTxx_MAX will get
rounded.  So that's worth something.

			regards, tom lane


Commits

  1. Update additional float4/8 expected-output files.

  2. Fix float-to-integer coercions to handle edge cases correctly.

  3. Adjust new test case for more portability.