Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does T D[N] always declare an object of array type?

I'm confused about [dcl.array]/1:

In a declaration T D where D has the form

          D1 [ constant-expressionopt ] attribute-specifier-seqopt

and the type of the identifier in the declaration T D1 is “derived-declarator-type-list T”, then the type of the identifier of D is an array type; ...

Consider the declaration:

int (*p)[42];

This declaration satisfies the grammar described above (and does not satisfy the grammar described in previous paragraphs), so this paragraph should apply, thus we conclude that the type of p is an array type. However, we know that the type of p is pointer to array of 42 int, which is a pointer type.

Am I missing something? Or pointer to array of 42 int is indeed an array type?

like image 754
xskxzr Avatar asked Jun 12 '18 18:06

xskxzr


1 Answers

This is a bug of the wording of the standard. Of course, int (*p)[42]; is not an array type, but satisfies the grammar in [dcl.array]/1 (and does not satisfy the previous grammars in [dcl.meaning]/5, [dcl.meaning]/6, [dcl.ptr]/1, [dcl.ref]/1 or [dcl.mptr]/1), so [dcl.array]/1 should apply.

I have posted an editorial issue.

like image 153
xskxzr Avatar answered Oct 26 '22 21:10

xskxzr