gandalf_der_13te@feddit.org to Programmer Humor@programming.dev · 3 days agocan somebody confirm this pls?feddit.orgimagemessage-square21linkfedilinkarrow-up1142arrow-down11
arrow-up1141arrow-down1imagecan somebody confirm this pls?feddit.orggandalf_der_13te@feddit.org to Programmer Humor@programming.dev · 3 days agomessage-square21linkfedilink
minus-squareSavvyWolf@pawb.sociallinkfedilinkEnglisharrow-up59arrow-down1·3 days agoYou actually shouldn’t do this! This doesn’t introduce a new scope, so accidentally using x outside of the case block is UB. Instead you should introduce a new scope like so: switch (foo) { case BAZ: { int x = ...; foobar(x); } }
You actually shouldn’t do this!
This doesn’t introduce a new scope, so accidentally using
xoutside of the case block is UB. Instead you should introduce a new scope like so:switch (foo) { case BAZ: { int x = ...; foobar(x); } }