关于case语句中声明变量并初始化的注意事项

时间:2023-12-17 18:28:32

今天看到一句对这个问题特别精辟的总结,记录如下:

It is possible to transfer into a block, but not in a way that bypasses declarations with initialization. A program that jumps from a point where a local variable with automatic storage duration is not in scope to a point where it is in scope is ill-formed unless the variable has POD type (3.9) and is declared without an initializer (8.5).