On Tue, 6 Aug 2024, Alejandro Colomar wrote:

> > Next question for the specification, implementation and tests: how does 
> > this feature interact with the rules on external definitions (the contexts 
> > in which it's OK to refer to an identifier with internal or external 
> > linkage that's never defined - for example, a function, static or extern, 
> > with a declaration but no definition; see 6.9.1)?
> 
> Functions are not array types, so they don't apply.  It's a constraint
> violation --mandatory error-- to call __lengthof__(func).
> 
> VLAs cannot have static storage duration or file scope.  Any array that
> has static storage duration or extern linkage must be a normal array.
> Since normal arrays operands are not evaluated, __lengthof__ returns a
> constant expression, and there's no issue at all.
> 
> I can't think of any case where we'd have problems; do you have any
> other example?

static int f(), f2();
int a[10][10];
int x;

void
g()
{
  __lengthof__ (a[f()]); // Should be valid that f is not defined.
  int b[x][x];
  __lengthof__ (b[f2()]); // Should be invalid that f2 is not defined.
}

-- 
Joseph S. Myers
josmy...@redhat.com

Reply via email to