Re: new clang report

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

On mån, 2011-05-02 at 14:45 -0400, Tom Lane wrote:
> > 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".

Well, the intent of the switch actually appears to be rather "follow the
standard and do what it says" with the default behavior being the
questionable one. So we could easily settle on that you need to use
that switch, otherwise it's not supported. (This is actually quite
similar to the old days when some systems had -ffast-math the default.)

Btw., when you build a simple test program in the default mode, pow()
indeed returns Inf on overflow. There appear to be some code generation
or optimization problems when it builds the postgres code, because the
problem goes away with either -O0 or by inserting an elog or something
like that after the pow() call.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Merlin Moncure 2011-05-05 19:20:04 Re: Visibility map and hint bits
Previous Message Simon Riggs 2011-05-05 19:10:48 Re: Unlogged vs. In-Memory