https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93848
Alexander Monakov <amonakov at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |amonakov at gcc dot gnu.org
--- Comment #3 from Alexander Monakov <amonakov at gcc dot gnu.org> ---
Note that 6.5.6 takes care to allow unevaluated * operator:
If the result points one past the last element of the array object,
it shall not be used as the operand of a unary * operator that is
evaluated.
So for example there's no UB in
void bar_aux (int *);
void foo (void)
{
int i;
int *p = &i;
bar_aux (&p[1]);
}
In your example with 'bar', the formal evaluation in the expression 'p[1]' does
not create a copy of the array, it simply strips off one array dimension in the
pointed-to type. So I am pretty sure it was not an intention of the standard to
make that undefined. Perhaps the standard could be edited to make that clearer,
but there's no need to issue a warning here.