Joseph S. Myers wrote:-

> > which seems reasonable based on my understanding of composite types
> > of VLA types: that either satisfies the requirements of, and therefore
> > can be taken to be, the composite type.
> 
> I think the type's complete: the recursive application of the composite 
> type rules means that the composite of each [] and [VLA] pair is the 
> [VLA], yielding a composite type int (*(*(*)[d1()])[d2()])[d3()]; the 
> trouble being that d1(), d2() and d3() won't all have been evaluated when 
> the composite type is required.

Unfortunately the expression is a big mess.  I hope you'll permit me
to examine the slightly simpler

int
h(void)
{
  int r = (0 ? (int (*(*)[d1()])[]) p1(): (int (*(*)[])[d2()]) p2()
          )[a][b][c][d];
  return r;
}

which I believe is analogous and my front end similarly rejects.
The logic goes like so:

We are parsing a conditional expression.  We have the true and false
branches.  The branches have types

  int (*(*)[d1()])[]
  int (*(*)[])[d2()]

namely "pointer to incomplete array of ..." and "pointer to VLA of ...".

The unqualified forms of the pointed-to types are compatible.  
The conditional expression therefore has type "pointer to appropriately
qualified form of the composite type" by 6.5.15p6. 

For the composite type, 6.2.7p3 dash 1 applies, and the composite is
the VLA type.  That VLA type is derived indirectly from an incomplete
type, and hence subscripting that incomplete type falls foul of the
contraint on the subscript operator.

I believe your example is the same, just with an extra level of nesting
from the nested conditional expression.

If you disagree could you point out the error in my reasoning?

Neil.

Reply via email to