3 ms·
"LLVM considers infinite recursion to be UB, so the only valid way for this function to execute is to return true"
by davikrr 5y ago
"LLVM considers infinite recursion to be UB, so the only valid way for this function to execute is to return true"
- Winsaucerer 5y agoWhat does 'UB' stand for?
- the_only_law 5y agoUndefined Behavior
- loeg 5y agoUndefined Behavior.
- jasode 5y ago>"LLVM considers infinite recursion to be UB, Not sure why he used the word "recursion" since collatz() is not calling itself.
- tpush 5y agoHe means the general concept of recursion, of which looping is an implementation, so to speak.
- forgetfulness 5y agoIt's in the computability theory sense, since compilers and language specifications are symbolic math-heavy, and in math you model all these things as recursive functions, the terminology is applied uniformly.
- tomhallett 5y agoHow does LLVM decide this loop is unbounded? Is any `while(true)` loop considered UB and therefore replaced with `return true` or is there more advanced introspection of the ast (some limited set of the halting problem)?
- detaro 5y agoIt checks how the loop can be exited, assumes that the loop must exit and thus take the code path that exits it, and then applies optimizations to remove everything it doesn't need to find the result.
- andrewaylett 5y agoWhich isn't quite right: the C++ spec allows the compiler to assume that a loop without side-effects will terminate. And the only way the loop terminates will be by returning true.