The third one is just (x=x+1), because the middle bit is just always false and can be ignored.
I mean it could be right
Submitted 1 year ago by genfood@feddit.de to programmer_humor@programming.dev
https://i.imgur.com/EB2fRAa.jpg
Comments
abbadon420@lemm.ee 1 year ago
Hotzilla@sopuli.xyz 1 year ago
What if int overflows? Is it still false?
rhpp@programming.dev 1 year 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++
SpaceNoodle@lemmy.world 1 year ago
++x;
damium@programming.dev 1 year ago
The underutilized post increment operator.
TootSweet@lemmy.world 1 year ago
for (var y = MIN_INT; y <= MAX_INT; y++) { if (y == x + 1) { x = y; } }
xthexder@l.sw0.com 1 year ago
y <= MAX_INT
will never be false, since the loop will overflow and wrap around toMIN_INT
(You can escape code with
`backticks`
, and regular markdown rules)
nybble41@programming.dev 1 year ago
I’m fairly certain that last one is UB in C. The result of an assignment operator is not an lvalue, and even if it were it’s UB (at least in C99) to modify the stored value of an object more than once between two adjacent sequence points. It might work in C++, though.
Beanie@programming.dev 1 year ago
That was my first thought when trying to figure out what it did
yum13241@lemm.ee 1 year ago
You forgot
++x
.
Blamemeta@lemm.ee 1 year ago
When the metric is lines of code
mcmoor@bookwormstory.social 1 year ago
When the company tries to be cheeky and starts to count characters instead