On Thu, Oct 31, 2019 at 2:30 AM Hans Åberg <haber...@telia.com> wrote:
> > > On 31 Oct 2019, at 01:53, David Blaikie <dblai...@gmail.com> wrote: > > > >> Yes, but assuming that the GMP adheres to the C standard, there should > be no difference in the arithmetical values produced. > > > > 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): > > > > int f() { > > static int i = 0; > > return i++; > > } > > int f2(int i, int j) { > > return i; > > } > > int main() { > > return f2(f(), f()); > > } > > > > 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) > > Right, but that is something one would avoid when computing arithmetical > results. > 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.
_______________________________________________ cfe-users mailing list cfe-users@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users