for loop being ignored (optimized?) out
问题 I am using for/while loops for implementing a delay in my code. The duration of the delay is unimportant here though it is sufficiently large to be noticeable. Here is the code snippet. uint32_t i; // Do something useful for (i = 0; i < 50000000U; ++i) {} // Do something useful The issue I am observing is that this for loop won't get executed. It probably gets ignored/optimized by the compiler. However, if I qualify the loop counter i by volatile, the for loop seems to execute and I do notice