Albin Jose to Programming • 9 months agoWhat will happen if we put a semi-colon after a for loop in C++?message-square17fedilinkarrow-up120arrow-down15
arrow-up115arrow-down1message-squareWhat will happen if we put a semi-colon after a for loop in C++?Albin Jose to Programming • 9 months agomessage-square17fedilink
minus-square@[email protected]linkfedilink17•9 months agoThe loop will run to completion with no side effects. Unless it gets optimized away by the compiler or CPU.
minus-square@[email protected]linkfedilink13•9 months agoNow slap some commas in there and you can have side effects in the loop header. Guaranteed to confuse :)
minus-square@[email protected]linkfedilink3•9 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