This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Change default to -fno-math-errno


On Mon, 30 Oct 2017, Wilco Dijkstra wrote:

> Richard Biener wrote:
> > Should we also get the __ieee764_ entries used if the compiler sets
> > __NO_MATH_ERRNO__?  That is, if the librari advertises not setting errno
> > via math_errhandling is it still allowed to set/clobber errno anyways?
> 
> That's a good question! I checked and the math wrappers currently use
> __FINITE_MATH_ONLY__ to decide whether to use the IEEE754 version
> or the wrapper which sets errno. However that's actually incorrect given
> that the only purpose of the wrappers is to set errno, not to add IEEE
> handling (which is done in the math implementation).

The semantics of __*_finite definitely include finite-math-only, as they 
aren't all just disabling the wrappers (e.g. sysdeps/i386/i686/fpu/e_log.S 
has __log_finite separate from __ieee754_log).

> Note -ffinite-math-only appears to imply -fno-math-errno, eventhough
> this is not clear from the documentation - is that expected? In principle
> these options are orthogonal, setting errno due to a range error is still
> valid even if you don't use infinities or NaNs.

Well, it's expected for glibc (as an empirical observation about what the 
__*_finite entry points do).  It may not necessarily be an implication for 
GCC.  And given appropriate documentation, it doesn't necessarily 
contradict math_errhandling & MATH_ERRNO being nonzero (in that errno 
setting on underflow is implementation-defined in that case - glibc 
documents semantics involving setting errno on underflow to 0 but not 
necessarily otherwise, but could document the effects of 
-ffinite-math-only potentially disabling the errno setting on underflow to 
0).

-- 
Joseph S. Myers
joseph@codesourcery.com

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]