Is a pointer to an array of unknown size incomplete?

后端 未结 2 528
感动是毒
感动是毒 2021-01-06 20:11

3.9/6 N3797:

[...]

The type of a pointer to array of unknown size, or of a type defined by a typedef declaration to be an array of unkno

2条回答
  •  长发绾君心
    2021-01-06 20:37

    Like C++ statements, English sentences must be interpreted in context. The context of the quoted sentence makes its meaning perfectly clear. The paragraph reads (§3.9 [basic.types]/p6, the sentence you quoted is bolded):

    A class type (such as “class X”) might be incomplete at one point in a translation unit and complete later on; the type “class X” is the same type at both points. The declared type of an array object might be an array of incomplete class type and therefore incomplete; if the class type is completed later on in the translation unit, the array type becomes complete; the array type at those two points is the same type. The declared type of an array object might be an array of unknown size and therefore be incomplete at one point in a translation unit and complete later on; the array types at those two points (“array of unknown bound of T” and “array of N T”) are different types. The type of a pointer to array of unknown size, or of a type defined by a typedef declaration to be an array of unknown size, cannot be completed.

    Read in context, it's clearly saying that a "pointer to array of unknown bound of T" can't be "completed" into a "pointer to array of N T" in the way that an object declared as an "array of unknown bound of T"" can be later defined as an "array of N T"

提交回复
热议问题