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 6 months ago by genfood@feddit.de to programmer_humor@programming.dev
https://i.imgur.com/EB2fRAa.jpg
Comments
abbadon420@lemm.ee 6 months ago
Hotzilla@sopuli.xyz 6 months ago
What if int overflows? Is it still false?
rhpp@programming.dev 6 months 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 6 months ago
++x;
damium@programming.dev 6 months ago
The underutilized post increment operator.
TootSweet@lemmy.world 6 months ago
for (var y = MIN_INT; y <= MAX_INT; y++) { if (y == x + 1) { x = y; } }
xthexder@l.sw0.com 6 months 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 6 months 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 6 months ago
That was my first thought when trying to figure out what it did
yum13241@lemm.ee 6 months ago
You forgot
++x
.
Blamemeta@lemm.ee 6 months ago
When the metric is lines of code
mcmoor@bookwormstory.social 6 months ago
When the company tries to be cheeky and starts to count characters instead