Re: new clang report

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: new clang report
Date: 2011-05-02 18:45:49
Message-ID: 147.1304361949@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Peter Eisentraut <peter_e(at)gmx(dot)net> writes:
> On ons, 2011-02-09 at 20:30 +0200, Peter Eisentraut wrote:
>> Regression tests (world):
>>
>> --- src/test/regress/expected/float8.out
>> +++ src/test/regress/results/float8.out
>> @@ -384,7 +384,15 @@
>> SELECT '' AS bad, f.f1 * '1e200' from FLOAT8_TBL f;
>> ERROR: value out of range: overflow
>> SELECT '' AS bad, f.f1 ^ '1e200' from FLOAT8_TBL f;
>> -ERROR: value out of range: overflow
>> + bad | ?column?
>> +-----+----------
>> + | 0
>> + | NaN
>> + | NaN
>> + | NaN
>> + | NaN
>> +(5 rows)
>> +
>> SELECT 0 ^ 0 + 0 ^ 1 + 0 ^ 0.0 + 0 ^ 0.5;
>> ?column?
>> ----------

> So issue here is actually that clang has an option

> -fmath-errno
> Indicate that math functions should be treated as updating errno.

Really? It looks to me like the issue is that pow() is returning NaN
instead of Inf for an out-of-range result. That's a bug: the correct
result is *not* ill-defined, it's simply too large to represent.
If that has anything to do with errno, it's an implementation artifact
that's unrelated to the claimed meaning of the switch.

But I would also note that the Single Unix Spec is unequivocal about
this case:

If the correct value would cause overflow, +-HUGE_VAL is
returned, and errno is set to [ERANGE].

That's "IS set", not "may be set" as in some other cases. So this
behavior should not depend on any such compiler switch anyway, unless
the intent of the switch is "ignore the standard and do whatever we
feel like".

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Dickson S. Guedes 2011-05-02 19:23:38 Re: A small step towards more organized beta testing
Previous Message Josh Berkus 2011-05-02 18:12:51 A small step towards more organized beta testing