[PATCH v3] Change default to -fno-math-errno

Szabolcs Nagy Szabolcs.Nagy@arm.com
Thu Oct 4 14:07:00 GMT 2018


On 04/10/18 14:25, Jeff Law wrote:
> On 10/4/18 6:37 AM, Richard Biener wrote:
>> On Thu, Oct 4, 2018 at 2:06 PM Joseph Myers <joseph@codesourcery.com> wrote:
>>>
>>> On Thu, 4 Oct 2018, Richard Biener wrote:
>>>
>>>> The other issue is that we're treating -fno-math-errno as disabling
>>>> errno handling in general (not only for math functions).  That would
>>>
>>> Also, is it treated as meaning the math functions *do not set errno* (so a
>>> load of errno (or of anything that might be errno) before a math function
>>> call could be moved after the call)?
>>
>> Yes.  That's implicit in math functions becoming CONST.
> Right.  But I think this highlights the other issue here.  Namely that
> if the user's code does read errno, we don't know if the intent was to
> read errno from some other call before the math bits or the most recent
> math call.
> 

if (math_errhandling & MATH_ERRNO) == 0 a math
function may still set errno.

it can only set it if there was an error though,
not arbitrarily clobber it, but this means that

(1) reordering errno access around math calls is
invalid even with -fno-math-errno.

(2) user code reading errno after a math call can
assume it to be unmodified in exactly the same
cases with -fmath-errno and -fno-math-errno.

> So again, as much as I'd like to move to a world where we don't have to
> worry about errno for math functions, I'm not comfortable making that
> change, though I won't object if someone  with a stronger standards
> background says "just do it".
> 
> jeff
> 



More information about the Gcc-patches mailing list