https://gcc.gnu.org/bugzilla/show_bug.cgi?id=129069

--- Comment #3 from 谢鑫辉 <xhxxh at mail dot nwpu.edu.cn> ---
(In reply to Richard Biener from comment #1)
> so IMO this should be treated similarly (UB?).

For the VLA, the goto leaves the scope of the declaration, so C itself ends
the lifetime of arr and the gimplifier's implicit block just models that.
For a direct call there is no such scope: the call is a plain expression
statement in the function body, and the documented lifetime is "the end of
the block in which the function was called", which here is the end of the
function.  So under the current documentation the testcase is valid.

For comparison, the same testcase with plain __builtin_alloca (sizeof (int))
in place of __builtin_alloca_with_align works at -O0/-O1/-O2/-O3 with the
same compiler (it isn't folded), and alloca's storage lives until the
function returns.  Users may reasonably expect alloca_with_align to behave
like alloca plus an alignment.

If the intent is that a repeated execution within the same block ends the
lifetime of the previous allocation (i.e. VLA-like semantics), then I think
the documentation of __builtin_alloca_with_align should say so; currently
it does not.

Reply via email to