https://gcc.gnu.org/bugzilla/show_bug.cgi?id=129069
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jsm28 at gcc dot gnu.org,
| |rguenth at gcc dot gnu.org
--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
With VLAs there's implicit blocks added:
__attribute__((noipa)) int
f (int n)
{
int *p[2];
int i = 0;
again:
int arr[n];
p[i] = arr;
*p[i] = i;
if (++i < 2)
goto again;
return *p[0];
}
gets you
again:;
(void) SAVE_EXPR <n>;
{
int arr[0:(sizetype) ((long int) SAVE_EXPR <n> + -1)];
p[i] = (int *) &arr;
*p[i] = i;
if ( ++i <= 1)
{
// predicted unlikely by goto predictor.;
goto again;
}
return *p[0];
}
where I'll note the goto again will leave a try{}finally{} block:
try
{
i = 0;
again:
n.0 = n;
{
saved_stack.2 = __builtin_stack_save ();
try
{
...
arr.1 = __builtin_alloca_with_align (D.2980, 32);
p[i] = arr.1;
_14 = p[i];
*_14 = i;
i = i + 1;
if (i <= 1) goto <D.2982>; else goto <D.2983>;
<D.2982>:
// predicted unlikely by goto predictor.
goto again;
<D.2983>:
_15 = p[0];
D.2984 = *_15;
return D.2984;
}
finally
{
__builtin_stack_restore (saved_stack.2);
}
}
}
finally
{
p = {CLOBBER(eos)};
}
}
so IMO this should be treated similarly (UB?).