From Jason Turner

[dcl.array]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp0zkbt_a8/{from.md → to.md} +14 -14
tmp/tmp0zkbt_a8/{from.md → to.md} RENAMED
@@ -28,12 +28,12 @@ unknown bound of `T`”, except as specified below.
28
  A type of the form “array of `N` `U`” or “array of unknown bound of `U`”
29
  is an *array type*. The optional *attribute-specifier-seq* appertains to
30
  the array type.
31
 
32
  `U` is called the array *element type*; this type shall not be a
33
- placeholder type [[dcl.spec.auto]], a reference type, a function type,
34
- an array of unknown bound, or cv `void`.
35
 
36
  [*Note 1*: An array can be constructed from one of the fundamental
37
  types (except `void`), from a pointer, from a pointer to member, from a
38
  class, from an enumeration type, or from an array of known
39
  bound. — *end note*]
@@ -64,39 +64,39 @@ typedef const AA CAA; // type is ``array of 2 array of 3 const int''
64
  — *end example*]
65
 
66
  [*Note 2*: An “array of `N` *cv-qualifier-seq* `U`” has cv-qualified
67
  type; see  [[basic.type.qualifier]]. — *end note*]
68
 
69
- An object of type “array of `N` `U`” contains a contiguously allocated
70
- non-empty set of `N` subobjects of type `U`, known as the *elements* of
71
- the array, and numbered `0` to `N-1`.
72
 
73
  In addition to declarations in which an incomplete object type is
74
  allowed, an array bound may be omitted in some cases in the declaration
75
  of a function parameter [[dcl.fct]]. An array bound may also be omitted
76
  when an object (but not a non-static data member) of array type is
77
- initialized and the declarator is followed by an initializer (
78
- [[dcl.init]], [[class.mem]], [[expr.type.conv]], [[expr.new]]). In these
79
  cases, the array bound is calculated from the number of initial elements
80
  (say, `N`) supplied [[dcl.init.aggr]], and the type of the array is
81
  “array of `N` `U`”.
82
 
83
- Furthermore, if there is a preceding declaration of the entity in the
84
- same scope in which the bound was specified, an omitted array bound is
85
- taken to be the same as in that earlier declaration, and similarly for
86
- the definition of a static data member of a class.
87
 
88
  [*Example 3*:
89
 
90
  ``` cpp
91
  extern int x[10];
92
  struct S {
93
  static int y[10];
94
  };
95
 
96
- int x[]; // OK: bound is 10
97
- int S::y[]; // OK: bound is 10
98
 
99
  void f() {
100
  extern int x[];
101
  int i = sizeof(x); // error: incomplete object type
102
  }
@@ -106,11 +106,11 @@ void f() {
106
 
107
  [*Note 3*:
108
 
109
  When several “array of” specifications are adjacent, a multidimensional
110
  array type is created; only the first of the constant expressions that
111
- specify the bounds of the arrays may be omitted.
112
 
113
  [*Example 4*:
114
 
115
  ``` cpp
116
  int x3d[3][5][7];
 
28
  A type of the form “array of `N` `U`” or “array of unknown bound of `U`”
29
  is an *array type*. The optional *attribute-specifier-seq* appertains to
30
  the array type.
31
 
32
  `U` is called the array *element type*; this type shall not be a
33
+ reference type, a function type, an array of unknown bound, or
34
+ cv `void`.
35
 
36
  [*Note 1*: An array can be constructed from one of the fundamental
37
  types (except `void`), from a pointer, from a pointer to member, from a
38
  class, from an enumeration type, or from an array of known
39
  bound. — *end note*]
 
64
  — *end example*]
65
 
66
  [*Note 2*: An “array of `N` *cv-qualifier-seq* `U`” has cv-qualified
67
  type; see  [[basic.type.qualifier]]. — *end note*]
68
 
69
+ An object of type “array of `N` `U`” consists of a contiguously
70
+ allocated non-empty set of `N` subobjects of type `U`, known as the
71
+ *elements* of the array, and numbered `0` to `N-1`.
72
 
73
  In addition to declarations in which an incomplete object type is
74
  allowed, an array bound may be omitted in some cases in the declaration
75
  of a function parameter [[dcl.fct]]. An array bound may also be omitted
76
  when an object (but not a non-static data member) of array type is
77
+ initialized and the declarator is followed by an initializer
78
+ [[dcl.init]], [[class.mem]], [[expr.type.conv]], [[expr.new]]. In these
79
  cases, the array bound is calculated from the number of initial elements
80
  (say, `N`) supplied [[dcl.init.aggr]], and the type of the array is
81
  “array of `N` `U`”.
82
 
83
+ Furthermore, if there is a reachable declaration of the entity that
84
+ inhabits the same scope in which the bound was specified, an omitted
85
+ array bound is taken to be the same as in that earlier declaration, and
86
+ similarly for the definition of a static data member of a class.
87
 
88
  [*Example 3*:
89
 
90
  ``` cpp
91
  extern int x[10];
92
  struct S {
93
  static int y[10];
94
  };
95
 
96
+ int x[]; // OK, bound is 10
97
+ int S::y[]; // OK, bound is 10
98
 
99
  void f() {
100
  extern int x[];
101
  int i = sizeof(x); // error: incomplete object type
102
  }
 
106
 
107
  [*Note 3*:
108
 
109
  When several “array of” specifications are adjacent, a multidimensional
110
  array type is created; only the first of the constant expressions that
111
+ specify the bounds of the arrays can be omitted.
112
 
113
  [*Example 4*:
114
 
115
  ``` cpp
116
  int x3d[3][5][7];