Is an array pointer of unknown size incomplete?

3.9 / 6 N3797:

[...]

The type of a pointer to an array of unknown size or of a specific type by typedef declaration, to be an array of unknown size, cannot be completed.

It appears that a pointer to an array of unknown size is an incomplete type. If so, we would not be able to define an object pointer to an array of unknown size. But this is not so, because we can define an array of an unknown boundary.

#include <iostream>

using std::cout;
using std::endl;

int (*a)[] = (int(*)[])0x4243afff;

int main()
{

}

It compiles fine.

Demo

We could not have done this if it were an incomplete type. In fact: 3.9 / 5:

Objects should not be defined as incomplete types

The standard previously defined incomplete types as follows 3./5:

, , , (7.2) , . (3.9.1).

, . ?

, ?

+3
2

, . :

 int (*a)[];

a . *a . ( dyp ), , , , *a .

: , . cdhowie dyp:

extern int a[];
int b = sizeof a;  // error
int a[10];
int c = sizeof a;  // OK

int (*a)[]; ; sizeof *a .

+6

++, . . (§3.9 [basic.types]/p6, , , ):

(, "class X" ) ; "class X" - . , , ; , ; . , , ; ( " T" " N T" ) . typedef , .

, " T" "" " N T" , " T" " " N T "

0

All Articles