Actually, the rule 6.8.6.1 states:
A goto statement is not allowed to jump past any declarations of objects
with variably modified types.
In your code, there does not exist an object with variably modified types. alloca
does not declare an object (that the compiler has to care of). Thus, there is nothing like a scope for alloca
, and no reason for undefined behavior in the sense of rule 6.8.6.1.
EDIT
To elaborate the answer a bit: the "undefinedness" of the behavior in case of VLA is due to the promise of a declaration that an object is "known" within its scope (at language level). In general, a declaration sets a context for code execution. There is no need that it is executed at runtime. However, this is not true in case of VLA: here this promise is implemented partly at runtime, breaking C's static declaration approach. To avoid further conflicts that would lead to a dynamic typing system, rule 6.8.6.1 avoids such conflicts.
In contrast, at language level alloca
is simply a function; its call does not constitute any scope. It makes only a promise about its run-time behavior in case it is called. If it isn't called, we do not "expect" anything from a function. Thus, its pure existence does not raise any conflict: both cases (bypassing or non-bypassing) have a well defined semantic.