Why do compilers seems to be polite toward loops that do nothing and do not eliminate them?
Does the C standard require loops to take some time?
Example, the f
There is no minimal execution time for a C or C++ executable because execution time depends on many platform specific issues such as:
Some processors support multiplication, others don't. The processors that don't support multiplication would take longer to execute a program than a process that has multiplication instructions. Same with floating point.
The internal operating speed of a processor varies. There is a common unit of time measurement called a "clock cycle". Most processor vendors specify the duration of an instruction in clock cycles. This measurement may be difficult due to internal support, such as cache management.
Some processors have logic that can optimize the execution of instructions, or instruction patterns. One optimization is branch prediction.
Many platforms have interrupts. For example, there may be a "system tick" interrupt which allows the operating system to know when to switch execution to another program. Some are not so periodic, such as when I/O occurs. A minimum execution time cannot be guaranteed when the program gets interrupted.
Stating a minimum execution time would play havoc with the C and C++ language portability. Some platforms would want to execute code faster than the minimum time. Other platforms may not be able to achieve a minimum execution time (but they could benefit from a high level language like C).
Also, how would the time be measured?
Does the minimum execution time apply for delay loops or polling?