<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Oct 31, 2019 at 2:30 AM Hans Åberg <<a href="mailto:haberg-1@telia.com">haberg-1@telia.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br>
> On 31 Oct 2019, at 01:53, David Blaikie <<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>> wrote:<br>
> <br>
>> Yes, but assuming that the GMP adheres to the C standard, there should be no difference in the arithmetical values produced.<br>
> <br>
> Not necessarily - C (well, I don't know the C standard as well as I know the C++ standard, admittedly) does allow various variations (implementation and unspecified behavior, for instance). eg: order of evaluation of function arguments (not that this is likely to vary due to optimizations - and doesn't with clang to the best of my knowledge, but as an example of the /sort/ of thing):<br>
> <br>
>   int f() {<br>
>     static int i = 0;<br>
>     return i++;<br>
>   }<br>
>   int f2(int i, int j) {<br>
>     return i;<br>
>   }<br>
>   int main() {<br>
>     return f2(f(), f());<br>
>   }<br>
> <br>
> This program could exit with 0 or 1 - both results are valid interpretations of the program per the standard. (again, I don't know the C spec quite as well, so I'm not sure exactly what it says about this code)<br>
<br>
Right, but that is something one would avoid when computing arithmetical results.<br></blockquote><div><br>One would try to, yes - but that's sort of what the whole discussion is resolving around: Is the code correct? I don't know. I wouldn't assume it is (I'm not assuming it isn't either) - but without a reduced test case that gets to the root of the difference in behavior, we don't know if the code is correct.<br> </div></div></div>