Albin Jose@suppo.fi to Programming@programming.dev · 11 months agoWhat will happen if we put a semi-colon after a for loop in C++?message-square20fedilinkarrow-up115arrow-down12
arrow-up113arrow-down1message-squareWhat will happen if we put a semi-colon after a for loop in C++?Albin Jose@suppo.fi to Programming@programming.dev · 11 months agomessage-square20fedilink
minus-squareJakenVeina@lemm.eelinkfedilinkarrow-up16·11 months agoThe loop will run to completion with no side effects. Unless it gets optimized away by the compiler or CPU.
minus-squarevext01@lemmy.sdf.orglinkfedilinkarrow-up12·11 months agoNow slap some commas in there and you can have side effects in the loop header. Guaranteed to confuse :)
minus-squareMiaou@jlai.lulinkfedilinkarrow-up4arrow-down2·11 months agoIt’s actually ub, so it could also find the cure to cancer
The loop will run to completion with no side effects. Unless it gets optimized away by the compiler or CPU.
Now slap some commas in there and you can have side effects in the loop header.
Guaranteed to confuse :)
It’s actually ub, so it could also find the cure to cancer