------- Comment #17 from kreckel at ginac dot de 2006-11-06 22:23 ------- (In reply to comment #15) > Maybe scheduling would have the same issue. The fact that the result of the > division is not used is a red herring, though. Of course, the assumption is > that it's actually used.
For the record: Andrew was right and above statement is wrong. The standard explicitly mandates that unused code must not be removed unless the compiler can determine that it cannot raise an exception flag [F.8.1]: : Concern about side effects may inhibit code motion and removal of seemingly : useless code. For example, in : #include <fenv.h> : #pragma STDC FENV_ACCESS ON : void f(double x) : { : /* ... */ : for (i = 0; i < n; i++) x + 1; : /* ... */ : } : x + 1 might raise floating-point exceptions, so cannot be removed. And since : the loop body might not execute (maybe 0 ³ n), x + 1 cannot be moved out of : the loop. (Of course these optimizations are valid if the implementation can : rule out the nettlesome cases.) -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29186