257
you are viewing a single comment's thread
view the rest of the comments
[-] abbadon420@lemm.ee 31 points 2 years ago

The third one is just (x=x+1), because the middle bit is just always false and can be ignored.

[-] Hotzilla@sopuli.xyz 6 points 2 years ago

What if int overflows? Is it still false?

[-] rhpp@programming.dev 11 points 2 years ago

Still false, thanks to compiler optimizations. Remember that integer overflow is UB. (unless you're using unsigned int or a programming language which strictly defines integer overflow, possibly as an error)

P.S.: Assuming this is C/C++

[-] chellomere@lemmy.world 2 points 2 years ago* (last edited 2 years ago)

No, because it's UB, the compiler is free to do whatever, like making demons fly out of your nose

this post was submitted on 21 Oct 2023
257 points (94.8% liked)

Programmer Humor

25374 readers
1834 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

founded 2 years ago
MODERATORS