this post was submitted on 17 Mar 2025
1250 points (99.6% liked)

Programmer Humor

34426 readers
727 users here now

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

founded 5 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
[โ€“] barubary@infosec.exchange 0 points 23 hours ago (1 children)
for (int i = INT_MIN; ; i++) {    ...    if (i == INT_MAX) break;}
[โ€“] barsoap@lemm.ee 1 points 22 hours ago

Would you be bold enough to write if (i++ == INT_MAX) break? The result of the increment is never used, but an increment is being done, at least syntactically, and it overflows, at least theoretically, so maybe (I'm not 100% sure) the compiler could be allowed to break out into song because undefined behaviour allows anything to happen.