T D [N]是否总是声明一个数组类型的对象? [英] Does T D[N] always declare an object of array type?

查看:63
本文介绍了T D [N]是否总是声明一个数组类型的对象?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对 [dcl.array]/1 感到困惑:

在声明T D中,D的形式为

In a declaration T D where D has the form

         D1 [ constant-expression opt ] 属性说明符-seq opt

          D1 [ constant-expressionopt ] attribute-specifier-seqopt

,声明T D1中的标识符类型为" derived-declarator-type-list T",则D的标识符类型为数组类型; ...

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; ...

考虑声明:

int (*p)[42];

此声明满足上述语法(并且不满足前面段落中描述的语法),因此应应用此段落,因此我们得出结论,p的类型是数组类型.但是,我们知道p的类型是pointer to array of 42 int,这是指针类型.

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.

我错过了什么吗?还是pointer to array of 42 int确实是数组类型?

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

推荐答案

这是标准措辞的错误.当然,int (*p)[42];不是数组类型,但是满足> [dcl .array]/1 (并且不满足 [ dcl.意义]/5 , [dcl.意义]/6 , [dcl.ptr]/1 [dcl.ref]/1

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.

我已经发布了编辑问题.

这篇关于T D [N]是否总是声明一个数组类型的对象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆