Why is it OK to jump into the scope of an object of scalar type w/o an initializer?

后端 未结 2 1744
甜味超标
甜味超标 2021-01-05 11:30

When I\'m reading the C++ standard, it seems that the following code is perfectly fine according to the standard.

int main() {
   goto lol;
   {
      int x;         


        
2条回答
  •  孤独总比滥情好
    2021-01-05 12:02

    You'd use an uninitialized x anyways, since int x; is as uninitialized as it's going to get. The existence of an initializer makes of course a difference, because you'd be skipping it. int x = 5; for example initializes x, so it would make a difference if you jumped over it or not.

提交回复
热议问题