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:52:32Z
Lists: pgsql-bugs
Andrew Gierth <andrew@tao11.riddles.org.uk> writes:
> "Tom" == Tom Lane <tgl@sss.pgh.pa.us> writes:
>  Tom>      if (unlikely(num < (float4) INT_MIN || num >= (float4) INT_MAX || isnan(num)))

>     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.

			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.