this post was submitted on 11 Nov 2025
556 points (97.4% liked)
Programmer Humor
27322 readers
2231 users here now
Welcome to Programmer Humor!
This is a place where you can post jokes, memes, humor, etc. related to programming!
For sharing awful code theres also Programming Horror.
Rules
- Keep content in english
- No advertisements
- Posts must be related to programming or programmer topics
founded 2 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
Yeah, that example makes it reasonable. But the optimizer can do ridiculous stuff when it proves the loop never terminates and also assume it terminates.
The most famous example of UB bullshit is when some compilers run code that is impossible to reach just because there's an infinite loop on the file (not even in the same function).
The lovely part about UB is it’s non-causal. The compiler can go back in time and steal Halloween candy from you when you were five and still comply with the specification.