5 ms·
I think that's a great example of how optimisers have gone off the deep end: no reasonable human programmer would think "I can't figure out if this loop termina
by userbinator 9y ago
I think that's a great example of how optimisers have gone off the deep end: no reasonable human programmer would think "I can't figure out if this loop terminates, so let's just leave it out", but that appears to be the default behaviour in this case --- when what should happen when the optimiser "gives up" is that it should just translate the code verbatim.
- deleted 9y ago[deleted]
- adrianN 9y agoBut the optimizer doesn't give up in this case. It successfully figures out that the loop has no side effect except heating up your processor and eliminates it.
- iainmerrick 9y agoWhat's the advantage of eliminating the loop? If the compiler is able to do that analysis, why not flag the endless spin loop as a compilation error?
- kazagistar 9y agoLoop is inside a function, that can have no side effect conditionally. Function is used in multiple places and inlined. With inlined context, compiler can eliminate loop sometimes.
- deleted 9y ago[deleted]
- flamedoge 9y agoeffectively a no-op... isn't code after inf-loop also removed as it is considered unreachable?
- caf 9y agoN1528: Why undefined behavior for infinite loops? (Boehm) http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1528.htm http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1528.htm