Sujet : Re: Struct Error
De : ben (at) *nospam* bsb.me.uk (Ben Bacarisse)
Groupes : comp.lang.cDate : 22. Jan 2025, 22:00:52
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <87sepa36nv.fsf@bsb.me.uk>
References : 1 2
User-Agent : Gnus/5.13 (Gnus v5.13)
Kaz Kylheku <
643-408-1753@kylheku.com> writes:
On 2025-01-22, bart <bc@freeuk.com> wrote:
Gcc 14.1 gives me an error compiling this code:
>
struct vector;
struct scenet;
>
struct vector {
double x;
double y;
double z;
};
>
struct scenet {
struct vector center;
double radius;
struct scenet (*child)[];
};
>
The error is:
>
error: array type has incomplete element type 'struct scenet'
struct scenet (*child)[];
^~~~~
>
This looks like a bug to me. There is on reason why an
incomplete array type (a pointer to which /is/ allowed!)
should be constrained to have a complete element.
It may be a bug in the standard, but it's not a bug in the compiler:
6.7.6.2 Array declarators
Constraints
... The element type shall not be an incomplete or function type. ...
There is no dispensation that avoids this constraint when a pointer to
such an array is being declared (the constraint is on the array
declarator) nor when is type will be soon completed.
-- Ben.