Haren Visavadia wrote:
test.c: #include <assert.h> #include <stdio.h>volatile float x = 3; int main() { float a = 1 / x; x = a; assert(a == x); printf("a has value of %g \n",a); printf("x has value of %g \n",x); assert((int)a == 0); assert((int)x == 0); return 0; } Compile this gcc {-O0,-O1,-O2,-O3,-Os} You will notice it will always works (despite not using -ffloat-store) and not cause an assertion failure at all.
And so? Why would you expect this particular example to give an assertion error. I would not expect an assert error here. In unoptimized mode, you certainly do not expect it, and in optimized mode, I would expect the register tracker to know that a and x are in the same register at the point of assertion (and perhaps even eliminate the comparison entirely).
