News for hackers. Stuff that matters.
Re:Undefined behavior can result in time travel by ambrop7 on Friday June 27, 2014 @03:58PM (#7956013)
I'm wondering if the exception is when the preceding ring_bell() function never returns? Then there is no undefined behavior since the line with undefined behavior is never reached.

So one could conclude that the compiler has to prove termination of ring_bell() before performing the optimization discussed, which is impossible for just any external function.

Re:Undefined behavior can result in time travel by mihai_ionic on Friday June 27, 2014 @04:05PM (#7956044)
According to the C++11 standard, the compiler may assume that any loop terminates, so unless you mark ring_bell as [[noreturn]], the code will be assumed reachable.

Furthermore, when undefined behaviour is invoked anywhere within a program, the whole program is undefined.

Re:Undefined behavior can result in time travel by robryk on Friday June 27, 2014 @04:23PM (#7956112)
As far as I remember, you are wrong: a loop with side effects (either external IO or volatile reads/writes) is allowed to never terminate.