On Wed, 21 Jan 2026, Alejandro Colomar wrote:
> Hi Joseph,
>
> On Tue, Jan 20, 2026 at 10:11:28PM +0000, Joseph Myers wrote:
> > On Tue, 20 Jan 2026, Alejandro Colomar wrote:
> >
> > > +For a function declared as
> > > +
> > > +@smallexample
> > > +void f (int n, int a[n]);
> > > +@end smallexample
> > > +
> > > +A caller must provide a pointer to at least @code{n} elements,
> > > +and the function must not access more than @code{n} elements.
> >
> > That's misleading. "must provide" suggests UB for violation, which is not
> > the case; this is just about warnings.
>
> I am indeed suggesting a constraint violation and subsequent UB if the
> diagnostic is ignored.
We certainly shouldn't introduce UB for such code that is entirely valid
in ISO C.
> In the case of pointers to arrays:
>
> void k (int n, int (*p)[n]);
> void k (int n, int (*p)[n + 1]);
>
> The relevant text is n3685::6.7.7.3p6:
That's not relevant, since both of those declarations mean
void k (int n, int (*p)[*]);
and the array length expressions are never evaluated.
--
Joseph S. Myers
[email protected]