> > Because the call to isinf is optimized away even at -O0 in the latter > > case (isinf being a pure function), but not in the former. That could be > > deemed a little questionable though. The gap is eliminated at -O1. > > Thank you for explication. Is it gcc's expected behavior?
It is valid to eliminate calls to pure functions whose return value is not used, as they have no "external" effects. GCC 3.x doesn't do it at -O0, whereas 4.x does. > The configure script which is included in rrdtool[1] checks whether > the system has isinf() as below. > > #include <math.h> > int > main () > { > float f = 0.0; isinf(f) > ; > return 0; > } The test is clearly fragile. Assigning the return value of isinf to a variable should be sufficient for 4.0.x at -O0. -- Eric Botcazou