Subject: Re: [std-proposals] Remove infinite loop UB
From: Rand McRanderson (therandshow_at_[hidden])
Date: 2020-05-26 08:02:38
First time posting here. Regarding infinite loops, the situation we
have now is most embedded programmers use some form of infinite loop
tailored to their specific compiler and board. This means whenever
they change compilers or boards there is a chance things could break.
So giving some way for a programmer to signal, yes this is a
wait-for-interrupts loop according to the dictates of the platform
would be very helpful.
On the other hand, I can see where simply making infinite loops not
undefined behavior could cause problems, specifically in cases like
loop elimination for inline functions, it would become ambiguous if a
no-op loop for a particular function context is actually no-op or
intended to do a wait of some sort unless the compiler can be sure it
terminates. This could be mitigated by requiring infinite loops be
explicitly infinite, ie while(1) or for(;;)
The other danger is that by making code that previously was broken
(ie, has infinite loops, but those currently are being eliminated,
maybe the loops were originally added for a specific platform or had
specific annotations to make them work that were not portable), it
could change the behavior of existing code in a way that might be
surprising to a legacy project that is recompiling code where they had
been ignoring these old previously harmless infinite loops. Not sure
if that is a real danger though, might be a hypothetical situation
that would not occur in real life.
Overall, I really like the proposal of p1494. I would prefer probably
that it not be in cstdlib, just because a lot of embedded programmers
might not have that header available, but I can understand that there
might not be any better place to put it.
STD-PROPOSALS list run by firstname.lastname@example.org
Standard Proposals Archives on Google Groups