@wilfredh Seriously, what kind of stance is “If we can detect that your code has an infinite loop anywhere under any circumstances, we reserve the right to erase all your data.“? What is a “trivial” infinite loop anyway? Is it time for us all to review the halting problem? :) Like I said, I’m glad JavaScript is perfect and doesn’t have any quirky behavior like this.
@DavidAnson @wilfredh Not saying this is good ergonomics, but you have it backwards. The old rule was “_because_ we can’t solve the halting problem, but still want to be able to optimize, we need you to ensure for us that your loops do terminate (or do something else easily recognizable)”. The rules of the game were that the compiler was allowed to assume every trivial loop terminates so that it could do optimizations like raising or lowering unrelated code across loops.
@DavidAnson @wilfredh Many of the rules around undefined behavior in C++ are like this: they’re not just arbitrary dumb things, but rather a reasoned choice of prioritizing optimization over safety. That’s not an entirely illogical choice, particularly decades ago. It’s just fallen out of fashion now, for good reason.
(The other common sort of UB rule comes from prioritizing performance on some random machine that happened to exist when an early compiler was written and no longer matters.)
@jacobsa @wilfredh That makes sense, thank you for the explanation! That said, I’m pretty sure there were plenty of while(true) loops back in the day and it’s slightly terrifying to think all of those programs represent undefined behavior. :)
TIL that C++03 considered a file without a trailing newline to be undefined behaviour! https://stackoverflow.com/a/72377
This was fixed in C++11, but the problem was that #include was a textual operation that could produce invalid syntax if no newline was present.
Wilfred Hughes
Shared words: no, undefined, behaviour
Score: 45.5
I created a patch to a typescript project today, but accidentally reformatted it. When viewing my changes with difftastic, I didn't see any of the formatting changes!
This is kinda cool, but it would have annoyed the maintainer if I hadn't spotted it.
Today I learnt that .cxx is an extension used in some C++ projects because "xx" vaguely resembles "++" rotated! It makes sense, but I'd never spotted the similarity before.