Почему C ++ обеспечивает такое поведение при инициализации кроссов? [Дубликат]

Допустим, у меня есть код на C ++:

if (error)
    goto exit;
... 
// size_t i = 0; //error
size_t i;
i = 0;
...
exit:
    ...

Я понимаю, что мы не должны использоватьgoto, но все же почему

size_t i;
i = 0;

компилировать в то время какsize_t i = 0; Безразлично & APOS; т?

Почему такое поведение обеспечивается стандартом (упомянутым @SingerOfTheFall)?

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.

Ответы на вопрос(2)

Ваш ответ на вопрос