@dev oh I see you have a type error that for some reason the compiler is ignoring. Try -Werror=return-type ?

@dev Oh - I guess that’s not firing because the *compiler* looks at the control flow and says “you don’t actually reach the closing brace” and then something is happening lower down in LLVM to delete the loop?

@elfprince13 working theory is the since the ub loop is optimized out, somehow it keeps going beyond main

@dev @elfprince13 Yeah, you can take a look in Compiler Explorer and see that that is indeed the case. main is just empty, so it falls through to unreachable.

godbolt.org/z/nPzWzbvb7

@dev if you don’t write your infinite loops as the Collatz Conjecture that’s on you ;) but it doesn’t seem like the compiler should be allowed to treat the loop as infinite for the purposes of control flow analysis to suppress a warning about missing “return 0”, but then decide the behavior is undefined and can be finite.

@elfprince13 @dev As of C99 and C++ it is optional to have a return statement in main(). If control reaches the end of main() with no explicit return, it returns 0.

@elfprince13 @dev ah, but is the collatz conjecture good enough when c compilers are smart enough to disprove fermat's last theorem?

blog.regehr.org/archives/140

@elfprince13 @dev oh i see you've seen this already

nevertheless, a shining testament to the field of computer science. those mathematicians can't even disprove fermat's last theorem, smh

Sign in to participate in the conversation
Mastodon

General topic personal server.