Avoid wrong results for power() with NaN input on some platforms.

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

Commit: 3b7fba935ec086c10ac407852ba840e358893e9c
Author: Tom Lane <tgl@sss.pgh.pa.us>
Date: 2018-04-29T19:21:45Z
Releases: 9.5.13
Avoid wrong results for power() with NaN input on some platforms.

Per spec, the result of power() should be NaN if either input is NaN.
It appears that on some versions of Windows, the libc function does
return NaN, but it also sets errno = EDOM, confusing our code that
attempts to work around shortcomings of other platforms.  Hence, add
guard tests to avoid substituting a wrong result for the right one.

It's been like this for a long time (and the odd behavior only appears
in older MSVC releases, too) so back-patch to all supported branches.

Dang Minh Huong, reviewed by David Rowley

Discussion: https://postgr.es/m/75DB81BEEA95B445AE6D576A0A5C9E936A73E741@BPXM05GP.gisp.nec.co.jp

Files

Discussion