On Sun, Nov 14, 2010 at 7:07 AM, Charles R Harris <charlesr.har...@gmail.com > wrote:
> > Another possible solution is like so: > > static __attribute__ ((noinline)) int > fpecheck(int *status) > { > *status = PyUFunc_getfperr(); > return 0; > } > > static __attribute__ ((noinline)) int > fpeclear(int *status) > { > PyUFunc_clearfperr(); > return 0; > } > > int myfunc(void) > { > int status; > > fpeclear(&status); > do { > stuff; > } while (fpecheck(&status)); > return status; > } > > While this may work in this particular case because of compiler specifics, I don't think this creates a reliable ordering dependency because of the form of 'stuff'. It will be loop invariant, so the compiler may do as follows: do { result = arg1 / arg2; } while (fpecheck(&status)); Pulling out the loop-invariant statement: result = arg1 / arg2; do { } while (fpecheck(&status)); Since the loop doesn't use result, it may feel free to reorder: do { } while (fpecheck(&status)); result = arg1 / arg2; producing the bug again. -Mark
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion