Although I was hoping this wouldn't escalate this much, I'm afraid I can't but answer some of the latest remarks:
"3 In the abstract machine, all expressions are evaluated as specified by the semantics. An
actual implementation need not evaluate part of an expression if it can deduce that its
value is not used and that no needed side effects are produced (including any caused by
calling a function or accessing a volatile object)."
This talks about expressions. A FOR loop is NOT an expression. The expressions are used to control the FOR loop. So, the expressions are indeed used by the FOR loop, and as such they can't be eliminated. The fact the FOR loop has no block of statements is irrelevant. Besides, the grammar of the language wouldn't allow a FOR loop (and other similar constructs) without at least one statement in it, if the intent was for an empty FOR loop to act as nothing more than a comment.
And in this case, besides the expressions being used by the FOR loop (so it can loop), we also have a needed side effect, the delay effect itself. So, on both counts there is nothing to suggest the FOR should be completely eliminated.
"Accessing a volatile object, modifying an object, modifying a file, or calling a function
that does any of those operations are all side effects"
(The above does not imply this: "Calling a function is a side-effect, just like having a volatile loop iterator. So the compiler can't optimize it away, unless you explicitly inline the function.")
According to the above, calling a function by itself isn't enough to be a side effect. So, a function can contain no statements, or only a single statement, the same FOR loop (of the OP), which should be (according to some) eliminated as dead code, leaving the function empty. Basically, that would translate to no more than a JSR/BSR to a single RTS, and at this point, I, too, would be very happy if that got optimized away, as well.
"The compiler is free to optimize away code where the values aren't used and which doesn't contain side-effects."
(Again, the expressions are used to control the loop, so they need to stay.) To some people, delay = no-effect. If we accept this, then yes, the compiler is correct in that regard only. To me, however, delay = work, so it can't get removed.
"How on earth do you expect the compiler to understand what your code is a dead waiting loop? It doesn't know your application, so it interprets the code as it is required to do by the C language, that's all it can do."
No, I do NOT expect the compiler to understand the programmer's intentions. Quite the opposite, don't even try to. A compiler is only allowed to optimize what it knows for sure has no side effect (as the standard so wisely says). Anytime the compiler can't be certain, it should leave the code alone. It is, afterall, the responsibility of the programmer to write meaningful code, but certainly not the job of a compiler to decide what is or isn't meaningful, whenever that decision could go either way, as in this case.
I still think it's a mistake to eliminate such FOR loops as dead code, because they simply aren't dead (yet). Unless a universal decree comes out that says "software delays aren't allowed anymore."