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

拜拜、爱过 提交于 2019-11-30 20:39:58

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.

Isn't it still dangerous to jump over its definition and use uninitialized x?

But x would be uninitialized anyway, because it was declared without an initializer! So the goto might be skipping over assignment statements that set (sort-of-initialize) x, but it's not surprising that goto can skip over assignment statements; and the declaration itself doesn't actually do anything unless there's an initializer.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!