News for hackers. Stuff that matters.
Re:Do C compilers disprove Fermat's Last Theorem? by gojomo on Saturday May 01, 2010 @02:20AM (#1310211)
The alternate behavior, while initially non-intuitive, seems more useful to me, in usual scenarios. And the grandparent post's taxonomy including the idea of "partial correctness" also seems useful. So you'll have to justify your "must" a bit more.

In particular: a programmer who wants an infinite loop can get one easily enough. Code that is complex, and has no side-effects other than affecting termination, and never terminates is likely to be a bug. As long as users of an optimizer know that it makes this choice -- that this particular pedantic kind of 'correctness' is waived in the face of otherwise side-effect-less code -- it seems an implementor's choice. And lots of competent implementors seem to have chosen the path you say they "must" not do.

Re:Do C compilers disprove Fermat's Last Theorem? by barrkel on Saturday May 01, 2010 @02:29AM (#1310217)
If you accept the grandparent's argument on face value, you should accept that a compiler should be able to remove other do-nothing infinite loops, like in the example I mentioned elsewhere:

    for (;;)
        /* do nothing */;
    destroy_the_world(); /* has side-effects */
Why should a compiler remove the loop in the OP's case, but not remove the loop above? Do you accept that removing the loop changes the side-effects of the program?
Re:Do C compilers disprove Fermat's Last Theorem? by gojomo on Saturday May 01, 2010 @04:51AM (#1310322)
It does change the effects -- but in a predictable and possibly-useful way. A loop that doesn't exit or do any work itself is far more likely a bug than an intentional behavior; removing it like other do-nothing code may benefit far more programs seeking "optimization" than the alternative.