You 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 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);
}
}