<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body style="overflow-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;"><div dir="auto" style="overflow-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;"><br id="lineBreakAtBeginningOfMessage"><div><br><blockquote type="cite"><div>On Apr 14, 2025, at 12:12 PM, JeanHeyd Meneide <phdofthehouse@gmail.com> wrote:</div><br class="Apple-interchange-newline"><div><div dir="ltr"><div dir="ltr">On Mon, Apr 14, 2025 Jim Thomas <<a href="mailto:jaswthomas@sbcglobal.net">jaswthomas@sbcglobal.net</a>> wrote:</div><div class="gmail_quote gmail_quote_container"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div>EXAMPLE 3 in 6.7.13.8.3 (in N3467) seems wrong. I understand that if a function is declared with the <font face="Courier New">[[reproducible]]</font> attribute then the compiler can elide repeated calls with the same arguments. But two such calls to the <font face="Courier New">distance</font> function in the example could not be elided if status flags are cleared after the first call and tested after the second. The function can raise “overflow”, “underflow”, and “inexact” floating-point exceptions.<br></div></div></blockquote><div><br></div><div>     Both asking and trying to find a solution, here. Does this mean in addition to the FP_CONTRACT pragma, it needs to also turn off FENV_ACCESS to prevent having access to floating point status flags? </div></div></div></div></blockquote><div><br></div>That wouldn’t help.</div><div><br><blockquote type="cite"><div><div dir="ltr"><div class="gmail_quote gmail_quote_container"><div>Does turning it off inside of a function mean a function cannot change those flags anymore, or does it just mean that the function itself won't access those flags? </div></div></div></div></blockquote><div><br></div>The latter.</div><div><br><blockquote type="cite"><div><div dir="ltr"><div class="gmail_quote gmail_quote_container"><div>The former, I think, would solve this problem, but the latter doesn't help for the example I don't believe. </div></div></div></div></blockquote><div><br></div>Correct.</div><div><br><blockquote type="cite"><div><div dir="ltr"><div class="gmail_quote gmail_quote_container"><div>(And, fi that is the case, do we then need to look into explicitly asserting that the floating point flags / exceptions are not active?)</div></div></div></div></blockquote></div><div><blockquote type="cite"><div><div dir="ltr"><div class="gmail_quote gmail_quote_container"><div><br></div><div>     If we did want to make such a function reproducible, what would you change to make it that way?</div></div></div></div></blockquote><div><br></div><div><br></div><div>The function could be written so that it doesn’t change the flags, e.g. with</div><div><br></div><div><font face="Courier New">#pragma STDC FP_CONTRACT OFF</font></div><div><font face="Courier New">#pragma STDC FENV_ACCESS ON</font></div><div><font face="Courier New">fenv_t save_env;</font></div><div><font face="Courier New">double d;</font></div><div><font face="Courier New">fegetenv(&save_env);</font></div><div><font face="Courier New">fesetenv(FE_DFL_ENV);</font></div><div><font face="Courier New">double d = sqrt(x[0]*x[0] + x[1]*x[1]);</font></div><div><font face="Courier New">fesetenv(&save_env);</font></div><div><font face="Courier New">return d;</font></div><div><br></div><div>Of course that would mean the function wouldn’t report floating-point exceptions.</div><div><br></div><div>(TS 18661-5 has <font face="Courier New">#pragma STDC FENV_EXCEPT FE_ALL_EXCEPT NO_FLAG</font> which means functions inside don’t set flags.)</div><div><br></div><div>- Jim Thomas</div><div><br></div><div><br></div><div><br></div><div><blockquote type="cite"><div dir="ltr"><div class="gmail_quote gmail_quote_container"></div></div></blockquote></div><blockquote type="cite"><div><div dir="ltr"><div class="gmail_quote gmail_quote_container"><div><br></div><div>Sincerely,</div><div>JeanHeyd</div></div></div>
</div></blockquote></div><br></div></body></html>