From Jason Turner

[basic.types]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpq2q6e01i/{from.md → to.md} +221 -131
tmp/tmpq2q6e01i/{from.md → to.md} RENAMED
@@ -1,74 +1,82 @@
1
  ## Types <a id="basic.types">[[basic.types]]</a>
2
 
3
- [[basic.types]] and the subclauses thereof impose requirements on
4
- implementations regarding the representation of types. There are two
5
- kinds of types: fundamental types and compound types. Types describe
6
- objects ([[intro.object]]), references ([[dcl.ref]]), or functions (
7
- [[dcl.fct]]).
8
 
9
  For any object (other than a base-class subobject) of trivially copyable
10
  type `T`, whether or not the object holds a valid value of type `T`, the
11
  underlying bytes ([[intro.memory]]) making up the object can be copied
12
- into an array of `char` or `unsigned` `char`.[^18] If the content of the
13
- array of `char` or `unsigned` `char` is copied back into the object, the
14
- object shall subsequently hold its original value.
 
 
15
 
16
  ``` cpp
17
  #define N sizeof(T)
18
  char buf[N];
19
  T obj; // obj initialized to its original value
20
- std::memcpy(buf, &obj, N); // between these two calls to std::memcpy,
21
- // obj might be modified
22
- std::memcpy(&obj, buf, N); // at this point, each subobject of obj of scalar type
23
- // holds its original value
24
  ```
25
 
 
 
26
  For any trivially copyable type `T`, if two pointers to `T` point to
27
  distinct `T` objects `obj1` and `obj2`, where neither `obj1` nor `obj2`
28
  is a base-class subobject, if the underlying bytes ([[intro.memory]])
29
  making up `obj1` are copied into `obj2`,[^19] `obj2` shall subsequently
30
  hold the same value as `obj1`.
31
 
 
 
32
  ``` cpp
33
  T* t1p;
34
  T* t2p;
35
  // provided that t2p points to an initialized object ...
36
  std::memcpy(t1p, t2p, sizeof(T));
37
  // at this point, every subobject of trivially copyable type in *t1p contains
38
  // the same value as the corresponding subobject in *t2p
39
  ```
40
 
 
 
41
  The *object representation* of an object of type `T` is the sequence of
42
- *N* `unsigned` `char` objects taken up by the object of type `T`, where
43
  *N* equals `sizeof(T)`. The *value representation* of an object is the
44
  set of bits that hold the value of type `T`. For trivially copyable
45
  types, the value representation is a set of bits in the object
46
  representation that determines a *value*, which is one discrete element
47
  of an *implementation-defined* set of values.[^20]
48
 
49
  A class that has been declared but not defined, an enumeration type in
50
- certain contexts ([[dcl.enum]]), or an array of unknown size or of
51
  incomplete element type, is an *incompletely-defined object type*. [^21]
52
- Incompletely-defined object types and the void types are *incomplete
53
- types* ([[basic.fundamental]]). Objects shall not be defined to have an
54
  incomplete type.
55
 
56
  A class type (such as “`class X`”) might be incomplete at one point in a
57
  translation unit and complete later on; the type “`class X`” is the same
58
  type at both points. The declared type of an array object might be an
59
  array of incomplete class type and therefore incomplete; if the class
60
  type is completed later on in the translation unit, the array type
61
  becomes complete; the array type at those two points is the same type.
62
- The declared type of an array object might be an array of unknown size
63
  and therefore be incomplete at one point in a translation unit and
64
  complete later on; the array types at those two points (“array of
65
  unknown bound of `T`” and “array of `N` `T`”) are different types. The
66
- type of a pointer to array of unknown size, or of a type defined by a
67
- `typedef` declaration to be an array of unknown size, cannot be
68
  completed.
69
 
 
 
70
  ``` cpp
71
  class X; // X is an incomplete type
72
  extern X* xp; // xp is a pointer to an incomplete type
73
  extern int arr[]; // the type of arr is incomplete
74
  typedef int UNKA[]; // UNKA is an incomplete type
@@ -91,52 +99,62 @@ void bar() {
91
  xp++; // OK: X is complete
92
  arrp++; // ill-formed: UNKA can't be completed
93
  }
94
  ```
95
 
96
- The rules for declarations and expressions describe in which contexts
97
- incomplete types are prohibited.
 
 
98
 
99
  An *object type* is a (possibly cv-qualified) type that is not a
100
- function type, not a reference type, and not a void type.
101
 
102
  Arithmetic types ([[basic.fundamental]]), enumeration types, pointer
103
  types, pointer to member types ([[basic.compound]]), `std::nullptr_t`,
104
- and cv-qualified versions of these types ([[basic.type.qualifier]]) are
105
  collectively called *scalar types*. Scalar types, POD classes (Clause 
106
- [[class]]), arrays of such types and *cv-qualified* versions of these
107
- types ([[basic.type.qualifier]]) are collectively called *POD types*.
108
- Cv-unqualified scalar types, trivially copyable class types (Clause 
109
- [[class]]), arrays of such types, and non-volatile const-qualified
110
- versions of these types ([[basic.type.qualifier]]) are collectively
111
- called *trivially copyable types*. Scalar types, trivial class types
112
- (Clause  [[class]]), arrays of such types and cv-qualified versions of
113
- these types ([[basic.type.qualifier]]) are collectively called *trivial
114
- types*. Scalar types, standard-layout class types (Clause  [[class]]),
115
- arrays of such types and cv-qualified versions of these types (
116
- [[basic.type.qualifier]]) are collectively called *standard-layout
117
- types*.
118
 
119
  A type is a *literal type* if it is:
120
 
121
- - `void`; or
122
  - a scalar type; or
123
  - a reference type; or
124
  - an array of literal type; or
125
- - a class type (Clause  [[class]]) that has all of the following
126
- properties:
127
  - it has a trivial destructor,
128
- - it is an aggregate type ([[dcl.init.aggr]]) or has at least one
129
- `constexpr` constructor or constructor template that is not a copy
130
- or move constructor, and
131
- - all of its non-static data members and base classes are of
132
- non-volatile literal types.
 
 
 
 
133
 
134
- If two types `T1` and `T2` are the same type, then `T1` and `T2` are
135
- *layout-compatible* types. Layout-compatible enumerations are described
136
- in  [[dcl.enum]]. Layout-compatible standard-layout structs and
137
- standard-layout unions are described in  [[class.mem]].
 
 
 
 
 
 
138
 
139
  ### Fundamental types <a id="basic.fundamental">[[basic.fundamental]]</a>
140
 
141
  Objects declared as characters (`char`) shall be large enough to store
142
  any member of the implementation’s basic character set. If a character
@@ -148,47 +166,54 @@ declared `unsigned` or `signed`. Plain `char`, `signed char`, and
148
  `unsigned char` are three distinct types, collectively called *narrow
149
  character types*. A `char`, a `signed char`, and an `unsigned char`
150
  occupy the same amount of storage and have the same alignment
151
  requirements ([[basic.align]]); that is, they have the same object
152
  representation. For narrow character types, all bits of the object
153
- representation participate in the value representation. For unsigned
154
- narrow character types, all possible bit patterns of the value
155
- representation represent numbers. These requirements do not hold for
156
- other types. In any particular implementation, a plain `char` object can
157
- take on either the same values as a `signed char` or an `unsigned
 
 
 
 
 
 
158
  char`; which one is *implementation-defined*. For each value *i* of type
159
  `unsigned char` in the range 0 to 255 inclusive, there exists a value
160
  *j* of type `char` such that the result of an integral conversion (
161
  [[conv.integral]]) from *i* to `char` is *j*, and the result of an
162
  integral conversion from *j* to `unsigned char` is *i*.
163
 
164
  There are five *standard signed integer types* : “`signed char`”,
165
- “`short int`”, “`int`”, “`long int`”, and “`long` `long` `int`”. In this
166
  list, each type provides at least as much storage as those preceding it
167
  in the list. There may also be *implementation-defined* *extended signed
168
  integer types*. The standard and extended signed integer types are
169
  collectively called *signed integer types*. Plain `int`s have the
170
- natural size suggested by the architecture of the execution
171
- environment[^22]; the other signed integer types are provided to meet
172
- special needs.
173
 
174
  For each of the standard signed integer types, there exists a
175
  corresponding (but different) *standard unsigned integer type*:
176
  “`unsigned char`”, “`unsigned short int`”, “`unsigned int`”,
177
- “`unsigned long int`”, and “`unsigned` `long` `long` `int`”, each of
178
- which occupies the same amount of storage and has the same alignment
179
  requirements ([[basic.align]]) as the corresponding signed integer
180
  type[^23]; that is, each signed integer type has the same object
181
  representation as its corresponding unsigned integer type. Likewise, for
182
  each of the extended signed integer types there exists a corresponding
183
  *extended unsigned integer type* with the same amount of storage and
184
  alignment requirements. The standard and extended unsigned integer types
185
  are collectively called *unsigned integer types*. The range of
186
- non-negative values of a *signed integer* type is a subrange of the
187
- corresponding *unsigned integer* type, and the value representation of
188
- each corresponding signed/unsigned type shall be the same. The standard
189
- signed integer types and standard unsigned integer types are
 
190
  collectively called the *standard integer types*, and the extended
191
  signed integer types and extended unsigned integer types are
192
  collectively called the *extended integer types*. The signed and
193
  unsigned integer types shall satisfy the constraints given in the C
194
  standard, section 5.2.4.2.1.
@@ -204,63 +229,76 @@ same size, signedness, and alignment requirements ([[basic.align]]) as
204
  one of the other integral types, called its *underlying type*. Types
205
  `char16_t` and `char32_t` denote distinct types with the same size,
206
  signedness, and alignment as `uint_least16_t` and `uint_least32_t`,
207
  respectively, in `<cstdint>`, called the underlying types.
208
 
209
- Values of type `bool` are either `true` or `false`.[^25] There are no
210
- `signed`, `unsigned`, `short`, or `long bool` types or values. Values of
211
- type `bool` participate in integral promotions ([[conv.prom]]).
 
 
 
 
212
 
213
  Types `bool`, `char`, `char16_t`, `char32_t`, `wchar_t`, and the signed
214
  and unsigned integer types are collectively called *integral*
215
  types.[^26] A synonym for integral type is *integer type*. The
216
  representations of integral types shall define values by use of a pure
217
- binary numeration system.[^27] this International Standard permits 2’s
218
- complement, 1’s complement and signed magnitude representations for
219
- integral types.
220
 
221
- There are three *floating point* types: `float`, `double`, and
 
 
 
 
222
  `long double`. The type `double` provides at least as much precision as
223
  `float`, and the type `long double` provides at least as much precision
224
  as `double`. The set of values of the type `float` is a subset of the
225
  set of values of the type `double`; the set of values of the type
226
- `double` is a subset of the set of values of the type `long` `double`.
227
- The value representation of floating-point types is
228
- *implementation-defined*. *Integral* and *floating* types are
229
- collectively called *arithmetic* types. Specializations of the standard
230
- template `std::numeric_limits` ([[support.limits]]) shall specify the
231
- maximum and minimum values of each arithmetic type for an
232
- implementation.
233
 
234
- The `void` type has an empty set of values. The `void` type is an
235
- incomplete type that cannot be completed. It is used as the return type
236
- for functions that do not return a value. Any expression can be
237
- explicitly converted to type *cv* `void` ([[expr.cast]]). An expression
238
- of type `void` shall be used only as an expression statement (
 
 
 
 
 
 
 
 
 
239
  [[stmt.expr]]), as an operand of a comma expression ([[expr.comma]]),
240
  as a second or third operand of `?:` ([[expr.cond]]), as the operand of
241
  `typeid`, `noexcept`, or `decltype`, as the expression in a return
242
- statement ([[stmt.return]]) for a function with the return type `void`,
243
- or as the operand of an explicit conversion to type cv `void`.
 
244
 
245
  A value of type `std::nullptr_t` is a null pointer constant (
246
  [[conv.ptr]]). Such values participate in the pointer and the pointer to
247
  member conversions ([[conv.ptr]], [[conv.mem]]).
248
  `sizeof(std::nullptr_t)` shall be equal to `sizeof(void*)`.
249
 
250
- Even if the implementation defines two or more basic types to have the
251
- same value representation, they are nevertheless different types.
 
252
 
253
  ### Compound types <a id="basic.compound">[[basic.compound]]</a>
254
 
255
  Compound types can be constructed in the following ways:
256
 
257
  - *arrays* of objects of a given type,  [[dcl.array]];
258
  - *functions*, which have parameters of given types and return `void` or
259
  references or objects of a given type,  [[dcl.fct]];
260
- - *pointers* to `void` or objects or functions (including static members
261
- of classes) of a given type,  [[dcl.ptr]];
262
  - *references* to objects or functions of a given type,  [[dcl.ref]].
263
  There are two types of references:
264
  - *lvalue reference*
265
  - *rvalue reference*
266
  - *classes* containing a sequence of objects of various types (Clause 
@@ -271,50 +309,88 @@ Compound types can be constructed in the following ways:
271
  - *unions*, which are classes capable of containing objects of different
272
  types at different times,  [[class.union]];
273
  - *enumerations*, which comprise a set of named constant values. Each
274
  distinct enumeration constitutes a different *enumerated type*, 
275
  [[dcl.enum]];
276
- - *pointers to non-static* [^28] *class members*, which identify members
277
  of a given type within objects of a given class,  [[dcl.mptr]].
278
 
279
  These methods of constructing types can be applied recursively;
280
  restrictions are mentioned in  [[dcl.ptr]], [[dcl.array]], [[dcl.fct]],
281
  and  [[dcl.ref]]. Constructing a type such that the number of bytes in
282
  its object representation exceeds the maximum value representable in the
283
  type `std::size_t` ([[support.types]]) is ill-formed.
284
 
285
- The type of a pointer to `void` or a pointer to an object type is called
286
- an *object pointer type*. A pointer to `void` does not have a
287
- pointer-to-object type, however, because `void` is not an object type.
 
 
 
288
  The type of a pointer that can designate a function is called a
289
  *function pointer type*. A pointer to objects of type `T` is referred to
290
- as a “pointer to `T`. a pointer to an object of type `int` is referred
291
- to as “pointer to `int` ” and a pointer to an object of class `X` is
292
- called a pointer to `X`.” Except for pointers to static members, text
293
- referring to “pointersdoes not apply to pointers to members. Pointers
294
- to incomplete types are allowed although there are restrictions on what
295
- can be done with them ([[basic.align]]). A valid value of an object
296
- pointer type represents either the address of a byte in memory (
297
- [[intro.memory]]) or a null pointer ([[conv.ptr]]). If an object of
298
- type `T` is located at an address `A`, a pointer of type *cv* `T*` whose
299
- value is the address `A` is said to *point to* that object, regardless
300
- of how the value was obtained. For instance, the address one past the
301
- end of an array ([[expr.add]]) would be considered to point to an
302
- unrelated object of the array’s element type that might be located at
303
- that address. There are further restrictions on pointers to objects with
304
- dynamic storage duration; see  [[basic.stc.dynamic.safety]]. The value
305
- representation of pointer types is *implementation-defined*. Pointers to
306
- cv-qualified and cv-unqualified versions ([[basic.type.qualifier]]) of
307
- layout-compatible types shall have the same value representation and
308
- alignment requirements ([[basic.align]]). Pointers to over-aligned
309
- types ([[basic.align]]) have no special representation, but their range
310
- of valid values is restricted by the extended alignment requirement.
311
- This International Standard specifies only two ways of obtaining such a
312
- pointer: taking the address of a valid object with an over-aligned type,
313
- and using one of the runtime pointer alignment functions. An
314
- implementation may provide other means of obtaining a valid pointer
315
- value for an over-aligned type.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
316
 
317
  A pointer to cv-qualified ([[basic.type.qualifier]]) or cv-unqualified
318
  `void` can be used to point to objects of unknown type. Such a pointer
319
  shall be able to hold any object pointer. An object of type cv `void*`
320
  shall have the same representation and alignment requirements as
@@ -325,12 +401,12 @@ cv `char*`.
325
  A type mentioned in  [[basic.fundamental]] and  [[basic.compound]] is a
326
  *cv-unqualified type*. Each type which is a cv-unqualified complete or
327
  incomplete object type or is `void` ([[basic.types]]) has three
328
  corresponding cv-qualified versions of its type: a *const-qualified*
329
  version, a *volatile-qualified* version, and a
330
- *const-volatile-qualified* version. The term *object type* (
331
- [[intro.object]]) includes the cv-qualifiers specified in the
332
  *decl-specifier-seq* ([[dcl.spec]]), *declarator* (Clause 
333
  [[dcl.decl]]), *type-id* ([[dcl.name]]), or *new-type-id* (
334
  [[expr.new]]) when the object is created.
335
 
336
  - A *const object* is an object of type `const T` or a non-mutable
@@ -342,16 +418,16 @@ version, a *volatile-qualified* version, and a
342
  volatile object, or a non-mutable volatile subobject of a const
343
  object.
344
 
345
  The cv-qualified or cv-unqualified versions of a type are distinct
346
  types; however, they shall have the same representation and alignment
347
- requirements ([[basic.align]]).[^29]
348
 
349
  A compound type ([[basic.compound]]) is not cv-qualified by the
350
  cv-qualifiers (if any) of the types from which it is compounded. Any
351
- cv-qualifiers applied to an array type affect the array element type,
352
- not the array type ([[dcl.array]]).
353
 
354
  See  [[dcl.fct]] and  [[class.this]] regarding function types that have
355
  *cv-qualifier*s.
356
 
357
  There is a partial ordering on cv-qualifiers, so that a type can be said
@@ -368,24 +444,38 @@ constitute this ordering.
368
  | no cv-qualifier | < | `const volatile` |
369
  | `const` | < | `const volatile` |
370
  | `volatile` | < | `const volatile` |
371
 
372
 
373
- In this International Standard, the notation *cv* (or *cv1*, *cv2*,
374
- etc.), used in the description of types, represents an arbitrary set of
375
  cv-qualifiers, i.e., one of {`const`}, {`volatile`}, {`const`,
376
- `volatile`}, or the empty set. Cv-qualifiers applied to an array type
377
- attach to the underlying element type, so the notation “*cv* `T`,” where
378
- `T` is an array type, refers to an array whose elements are
379
- so-qualified. An array type whose elements are cv-qualified is also
380
- considered to have the same cv-qualifications as its elements.
 
 
 
 
 
 
 
 
 
 
 
 
381
 
382
  ``` cpp
383
  typedef char CA[5];
384
  typedef const char CC;
385
  CC arr1[5] = { 0 };
386
  const CA arr2 = { 0 };
387
  ```
388
 
389
- The type of both `arr1` and `arr2` is “array of 5 `const char`,” and the
390
- array type is considered to be `const`-qualified.
 
 
391
 
 
1
  ## Types <a id="basic.types">[[basic.types]]</a>
2
 
3
+ [*Note 1*: [[basic.types]] and the subclauses thereof impose
4
+ requirements on implementations regarding the representation of types.
5
+ There are two kinds of types: fundamental types and compound types.
6
+ Types describe objects ([[intro.object]]), references ([[dcl.ref]]),
7
+ or functions ([[dcl.fct]]). — *end note*]
8
 
9
  For any object (other than a base-class subobject) of trivially copyable
10
  type `T`, whether or not the object holds a valid value of type `T`, the
11
  underlying bytes ([[intro.memory]]) making up the object can be copied
12
+ into an array of `char`, `unsigned char`, or `std::byte` (
13
+ [[cstddef.syn]]). [^18] If the content of that array is copied back into
14
+ the object, the object shall subsequently hold its original value.
15
+
16
+ [*Example 1*:
17
 
18
  ``` cpp
19
  #define N sizeof(T)
20
  char buf[N];
21
  T obj; // obj initialized to its original value
22
+ std::memcpy(buf, &obj, N); // between these two calls to std::memcpy, obj might be modified
23
+ std::memcpy(&obj, buf, N); // at this point, each subobject of obj of scalar type holds its original value
 
 
24
  ```
25
 
26
+ — *end example*]
27
+
28
  For any trivially copyable type `T`, if two pointers to `T` point to
29
  distinct `T` objects `obj1` and `obj2`, where neither `obj1` nor `obj2`
30
  is a base-class subobject, if the underlying bytes ([[intro.memory]])
31
  making up `obj1` are copied into `obj2`,[^19] `obj2` shall subsequently
32
  hold the same value as `obj1`.
33
 
34
+ [*Example 2*:
35
+
36
  ``` cpp
37
  T* t1p;
38
  T* t2p;
39
  // provided that t2p points to an initialized object ...
40
  std::memcpy(t1p, t2p, sizeof(T));
41
  // at this point, every subobject of trivially copyable type in *t1p contains
42
  // the same value as the corresponding subobject in *t2p
43
  ```
44
 
45
+ — *end example*]
46
+
47
  The *object representation* of an object of type `T` is the sequence of
48
+ *N* `unsigned char` objects taken up by the object of type `T`, where
49
  *N* equals `sizeof(T)`. The *value representation* of an object is the
50
  set of bits that hold the value of type `T`. For trivially copyable
51
  types, the value representation is a set of bits in the object
52
  representation that determines a *value*, which is one discrete element
53
  of an *implementation-defined* set of values.[^20]
54
 
55
  A class that has been declared but not defined, an enumeration type in
56
+ certain contexts ([[dcl.enum]]), or an array of unknown bound or of
57
  incomplete element type, is an *incompletely-defined object type*. [^21]
58
+ Incompletely-defined object types and cv `void` are *incomplete types* (
59
+ [[basic.fundamental]]). Objects shall not be defined to have an
60
  incomplete type.
61
 
62
  A class type (such as “`class X`”) might be incomplete at one point in a
63
  translation unit and complete later on; the type “`class X`” is the same
64
  type at both points. The declared type of an array object might be an
65
  array of incomplete class type and therefore incomplete; if the class
66
  type is completed later on in the translation unit, the array type
67
  becomes complete; the array type at those two points is the same type.
68
+ The declared type of an array object might be an array of unknown bound
69
  and therefore be incomplete at one point in a translation unit and
70
  complete later on; the array types at those two points (“array of
71
  unknown bound of `T`” and “array of `N` `T`”) are different types. The
72
+ type of a pointer to array of unknown bound, or of a type defined by a
73
+ `typedef` declaration to be an array of unknown bound, cannot be
74
  completed.
75
 
76
+ [*Example 3*:
77
+
78
  ``` cpp
79
  class X; // X is an incomplete type
80
  extern X* xp; // xp is a pointer to an incomplete type
81
  extern int arr[]; // the type of arr is incomplete
82
  typedef int UNKA[]; // UNKA is an incomplete type
 
99
  xp++; // OK: X is complete
100
  arrp++; // ill-formed: UNKA can't be completed
101
  }
102
  ```
103
 
104
+ *end example*]
105
+
106
+ [*Note 2*: The rules for declarations and expressions describe in which
107
+ contexts incomplete types are prohibited. — *end note*]
108
 
109
  An *object type* is a (possibly cv-qualified) type that is not a
110
+ function type, not a reference type, and not cv `void`.
111
 
112
  Arithmetic types ([[basic.fundamental]]), enumeration types, pointer
113
  types, pointer to member types ([[basic.compound]]), `std::nullptr_t`,
114
+ and cv-qualified ([[basic.type.qualifier]]) versions of these types are
115
  collectively called *scalar types*. Scalar types, POD classes (Clause 
116
+ [[class]]), arrays of such types and cv-qualified versions of these
117
+ types are collectively called *POD types*. Cv-unqualified scalar types,
118
+ trivially copyable class types (Clause  [[class]]), arrays of such
119
+ types, and cv-qualified versions of these types are collectively called
120
+ *trivially copyable types*. Scalar types, trivial class types (Clause 
121
+ [[class]]), arrays of such types and cv-qualified versions of these
122
+ types are collectively called *trivial types*. Scalar types,
123
+ standard-layout class types (Clause  [[class]]), arrays of such types
124
+ and cv-qualified versions of these types are collectively called
125
+ *standard-layout types*.
 
 
126
 
127
  A type is a *literal type* if it is:
128
 
129
+ - possibly cv-qualified `void`; or
130
  - a scalar type; or
131
  - a reference type; or
132
  - an array of literal type; or
133
+ - a possibly cv-qualified class type (Clause  [[class]]) that has all of
134
+ the following properties:
135
  - it has a trivial destructor,
136
+ - it is either a closure type ([[expr.prim.lambda.closure]]), an
137
+ aggregate type ([[dcl.init.aggr]]), or has at least one constexpr
138
+ constructor or constructor template (possibly inherited (
139
+ [[namespace.udecl]]) from a base class) that is not a copy or move
140
+ constructor,
141
+ - if it is a union, at least one of its non-static data members is of
142
+ non-volatile literal type, and
143
+ - if it is not a union, all of its non-static data members and base
144
+ classes are of non-volatile literal types.
145
 
146
+ [*Note 3*: A literal type is one for which it might be possible to
147
+ create an object within a constant expression. It is not a guarantee
148
+ that it is possible to create such an object, nor is it a guarantee that
149
+ any object of that type will usable in a constant
150
+ expression. — *end note*]
151
+
152
+ Two types *cv1* `T1` and *cv2* `T2` are *layout-compatible* types if
153
+ `T1` and `T2` are the same type, layout-compatible enumerations (
154
+ [[dcl.enum]]), or layout-compatible standard-layout class types (
155
+ [[class.mem]]).
156
 
157
  ### Fundamental types <a id="basic.fundamental">[[basic.fundamental]]</a>
158
 
159
  Objects declared as characters (`char`) shall be large enough to store
160
  any member of the implementation’s basic character set. If a character
 
166
  `unsigned char` are three distinct types, collectively called *narrow
167
  character types*. A `char`, a `signed char`, and an `unsigned char`
168
  occupy the same amount of storage and have the same alignment
169
  requirements ([[basic.align]]); that is, they have the same object
170
  representation. For narrow character types, all bits of the object
171
+ representation participate in the value representation.
172
+
173
+ [*Note 1*: A bit-field of narrow character type whose length is larger
174
+ than the number of bits in the object representation of that type has
175
+ padding bits; see  [[class.bit]]. *end note*]
176
+
177
+ For unsigned narrow character types, each possible bit pattern of the
178
+ value representation represents a distinct number. These requirements do
179
+ not hold for other types. In any particular implementation, a plain
180
+ `char` object can take on either the same values as a `signed char` or
181
+ an `unsigned
182
  char`; which one is *implementation-defined*. For each value *i* of type
183
  `unsigned char` in the range 0 to 255 inclusive, there exists a value
184
  *j* of type `char` such that the result of an integral conversion (
185
  [[conv.integral]]) from *i* to `char` is *j*, and the result of an
186
  integral conversion from *j* to `unsigned char` is *i*.
187
 
188
  There are five *standard signed integer types* : “`signed char`”,
189
+ “`short int`”, “`int`”, “`long int`”, and “`long long int`”. In this
190
  list, each type provides at least as much storage as those preceding it
191
  in the list. There may also be *implementation-defined* *extended signed
192
  integer types*. The standard and extended signed integer types are
193
  collectively called *signed integer types*. Plain `int`s have the
194
+ natural size suggested by the architecture of the execution environment
195
+ [^22]; the other signed integer types are provided to meet special
196
+ needs.
197
 
198
  For each of the standard signed integer types, there exists a
199
  corresponding (but different) *standard unsigned integer type*:
200
  “`unsigned char`”, “`unsigned short int`”, “`unsigned int`”,
201
+ “`unsigned long int`”, and “`unsigned long long int`”, each of which
202
+ occupies the same amount of storage and has the same alignment
203
  requirements ([[basic.align]]) as the corresponding signed integer
204
  type[^23]; that is, each signed integer type has the same object
205
  representation as its corresponding unsigned integer type. Likewise, for
206
  each of the extended signed integer types there exists a corresponding
207
  *extended unsigned integer type* with the same amount of storage and
208
  alignment requirements. The standard and extended unsigned integer types
209
  are collectively called *unsigned integer types*. The range of
210
+ non-negative values of a signed integer type is a subrange of the
211
+ corresponding unsigned integer type, the representation of the same
212
+ value in each of the two types is the same, and the value representation
213
+ of each corresponding signed/unsigned type shall be the same. The
214
+ standard signed integer types and standard unsigned integer types are
215
  collectively called the *standard integer types*, and the extended
216
  signed integer types and extended unsigned integer types are
217
  collectively called the *extended integer types*. The signed and
218
  unsigned integer types shall satisfy the constraints given in the C
219
  standard, section 5.2.4.2.1.
 
229
  one of the other integral types, called its *underlying type*. Types
230
  `char16_t` and `char32_t` denote distinct types with the same size,
231
  signedness, and alignment as `uint_least16_t` and `uint_least32_t`,
232
  respectively, in `<cstdint>`, called the underlying types.
233
 
234
+ Values of type `bool` are either `true` or `false`.[^25]
235
+
236
+ [*Note 2*: There are no `signed`, `unsigned`, `short`, or `long bool`
237
+ types or values. — *end note*]
238
+
239
+ Values of type `bool` participate in integral promotions (
240
+ [[conv.prom]]).
241
 
242
  Types `bool`, `char`, `char16_t`, `char32_t`, `wchar_t`, and the signed
243
  and unsigned integer types are collectively called *integral*
244
  types.[^26] A synonym for integral type is *integer type*. The
245
  representations of integral types shall define values by use of a pure
246
+ binary numeration system.[^27]
 
 
247
 
248
+ [*Example 1*: This International Standard permits two’s complement,
249
+ ones’ complement and signed magnitude representations for integral
250
+ types. — *end example*]
251
+
252
+ There are three *floating-point* types: `float`, `double`, and
253
  `long double`. The type `double` provides at least as much precision as
254
  `float`, and the type `long double` provides at least as much precision
255
  as `double`. The set of values of the type `float` is a subset of the
256
  set of values of the type `double`; the set of values of the type
257
+ `double` is a subset of the set of values of the type `long double`. The
258
+ value representation of floating-point types is
259
+ *implementation-defined*.
 
 
 
 
260
 
261
+ [*Note 3*: This International Standard imposes no requirements on the
262
+ accuracy of floating-point operations; see also 
263
+ [[support.limits]]. *end note*]
264
+
265
+ Integral and floating types are collectively called *arithmetic* types.
266
+ Specializations of the standard library template `std::numeric_limits` (
267
+ [[support.limits]]) shall specify the maximum and minimum values of each
268
+ arithmetic type for an implementation.
269
+
270
+ A type cv `void` is an incomplete type that cannot be completed; such a
271
+ type has an empty set of values. It is used as the return type for
272
+ functions that do not return a value. Any expression can be explicitly
273
+ converted to type cv `void` ([[expr.cast]]). An expression of type
274
+ cv `void` shall be used only as an expression statement (
275
  [[stmt.expr]]), as an operand of a comma expression ([[expr.comma]]),
276
  as a second or third operand of `?:` ([[expr.cond]]), as the operand of
277
  `typeid`, `noexcept`, or `decltype`, as the expression in a return
278
+ statement ([[stmt.return]]) for a function with the return type
279
+ cv `void`, or as the operand of an explicit conversion to type
280
+ cv `void`.
281
 
282
  A value of type `std::nullptr_t` is a null pointer constant (
283
  [[conv.ptr]]). Such values participate in the pointer and the pointer to
284
  member conversions ([[conv.ptr]], [[conv.mem]]).
285
  `sizeof(std::nullptr_t)` shall be equal to `sizeof(void*)`.
286
 
287
+ [*Note 4*: Even if the implementation defines two or more basic types
288
+ to have the same value representation, they are nevertheless different
289
+ types. — *end note*]
290
 
291
  ### Compound types <a id="basic.compound">[[basic.compound]]</a>
292
 
293
  Compound types can be constructed in the following ways:
294
 
295
  - *arrays* of objects of a given type,  [[dcl.array]];
296
  - *functions*, which have parameters of given types and return `void` or
297
  references or objects of a given type,  [[dcl.fct]];
298
+ - *pointers* to cv `void` or objects or functions (including static
299
+ members of classes) of a given type,  [[dcl.ptr]];
300
  - *references* to objects or functions of a given type,  [[dcl.ref]].
301
  There are two types of references:
302
  - *lvalue reference*
303
  - *rvalue reference*
304
  - *classes* containing a sequence of objects of various types (Clause 
 
309
  - *unions*, which are classes capable of containing objects of different
310
  types at different times,  [[class.union]];
311
  - *enumerations*, which comprise a set of named constant values. Each
312
  distinct enumeration constitutes a different *enumerated type*, 
313
  [[dcl.enum]];
314
+ - *pointers to non-static class members*, [^28] which identify members
315
  of a given type within objects of a given class,  [[dcl.mptr]].
316
 
317
  These methods of constructing types can be applied recursively;
318
  restrictions are mentioned in  [[dcl.ptr]], [[dcl.array]], [[dcl.fct]],
319
  and  [[dcl.ref]]. Constructing a type such that the number of bytes in
320
  its object representation exceeds the maximum value representable in the
321
  type `std::size_t` ([[support.types]]) is ill-formed.
322
 
323
+ The type of a pointer to cv `void` or a pointer to an object type is
324
+ called an *object pointer type*.
325
+
326
+ [*Note 1*: A pointer to `void` does not have a pointer-to-object type,
327
+ however, because `void` is not an object type. — *end note*]
328
+
329
  The type of a pointer that can designate a function is called a
330
  *function pointer type*. A pointer to objects of type `T` is referred to
331
+ as a “pointer to `T`”.
332
+
333
+ [*Example 1*: A pointer to an object of type `int` is referred to as
334
+ “pointer to `int`and a pointer to an object of class `X` is called a
335
+ “pointer to `X`”. *end example*]
336
+
337
+ Except for pointers to static members, text referring to “pointers” does
338
+ not apply to pointers to members. Pointers to incomplete types are
339
+ allowed although there are restrictions on what can be done with them (
340
+ [[basic.align]]). Every value of pointer type is one of the following:
341
+
342
+ - a *pointer to* an object or function (the pointer is said to *point*
343
+ to the object or function), or
344
+ - a *pointer past the end of* an object ([[expr.add]]), or
345
+ - the *null pointer value* ([[conv.ptr]]) for that type, or
346
+ - an *invalid pointer value*.
347
+
348
+ A value of a pointer type that is a pointer to or past the end of an
349
+ object *represents the address* of the first byte in memory (
350
+ [[intro.memory]]) occupied by the object [^29] or the first byte in
351
+ memory after the end of the storage occupied by the object,
352
+ respectively.
353
+
354
+ [*Note 2*: A pointer past the end of an object ([[expr.add]]) is not
355
+ considered to point to an unrelated object of the object’s type that
356
+ might be located at that address. A pointer value becomes invalid when
357
+ the storage it denotes reaches the end of its storage duration; see
358
+ [[basic.stc]]. — *end note*]
359
+
360
+ For purposes of pointer arithmetic ([[expr.add]]) and comparison (
361
+ [[expr.rel]], [[expr.eq]]), a pointer past the end of the last element
362
+ of an array `x` of n elements is considered to be equivalent to a
363
+ pointer to a hypothetical element `x[n]`. The value representation of
364
+ pointer types is *implementation-defined*. Pointers to layout-compatible
365
+ types shall have the same value representation and alignment
366
+ requirements ([[basic.align]]).
367
+
368
+ [*Note 3*: Pointers to over-aligned types ([[basic.align]]) have no
369
+ special representation, but their range of valid values is restricted by
370
+ the extended alignment requirement. — *end note*]
371
+
372
+ Two objects *a* and *b* are *pointer-interconvertible* if:
373
+
374
+ - they are the same object, or
375
+ - one is a standard-layout union object and the other is a non-static
376
+ data member of that object ([[class.union]]), or
377
+ - one is a standard-layout class object and the other is the first
378
+ non-static data member of that object, or, if the object has no
379
+ non-static data members, the first base class subobject of that
380
+ object ([[class.mem]]), or
381
+ - there exists an object *c* such that *a* and *c* are
382
+ pointer-interconvertible, and *c* and *b* are
383
+ pointer-interconvertible.
384
+
385
+ If two objects are pointer-interconvertible, then they have the same
386
+ address, and it is possible to obtain a pointer to one from a pointer to
387
+ the other via a `reinterpret_cast` ([[expr.reinterpret.cast]]).
388
+
389
+ [*Note 4*: An array object and its first element are not
390
+ pointer-interconvertible, even though they have the same
391
+ address. — *end note*]
392
 
393
  A pointer to cv-qualified ([[basic.type.qualifier]]) or cv-unqualified
394
  `void` can be used to point to objects of unknown type. Such a pointer
395
  shall be able to hold any object pointer. An object of type cv `void*`
396
  shall have the same representation and alignment requirements as
 
401
  A type mentioned in  [[basic.fundamental]] and  [[basic.compound]] is a
402
  *cv-unqualified type*. Each type which is a cv-unqualified complete or
403
  incomplete object type or is `void` ([[basic.types]]) has three
404
  corresponding cv-qualified versions of its type: a *const-qualified*
405
  version, a *volatile-qualified* version, and a
406
+ *const-volatile-qualified* version. The type of an object (
407
+ [[intro.object]]) includes the *cv-qualifier*s specified in the
408
  *decl-specifier-seq* ([[dcl.spec]]), *declarator* (Clause 
409
  [[dcl.decl]]), *type-id* ([[dcl.name]]), or *new-type-id* (
410
  [[expr.new]]) when the object is created.
411
 
412
  - A *const object* is an object of type `const T` or a non-mutable
 
418
  volatile object, or a non-mutable volatile subobject of a const
419
  object.
420
 
421
  The cv-qualified or cv-unqualified versions of a type are distinct
422
  types; however, they shall have the same representation and alignment
423
+ requirements ([[basic.align]]).[^30]
424
 
425
  A compound type ([[basic.compound]]) is not cv-qualified by the
426
  cv-qualifiers (if any) of the types from which it is compounded. Any
427
+ cv-qualifiers applied to an array type affect the array element type (
428
+ [[dcl.array]]).
429
 
430
  See  [[dcl.fct]] and  [[class.this]] regarding function types that have
431
  *cv-qualifier*s.
432
 
433
  There is a partial ordering on cv-qualifiers, so that a type can be said
 
444
  | no cv-qualifier | < | `const volatile` |
445
  | `const` | < | `const volatile` |
446
  | `volatile` | < | `const volatile` |
447
 
448
 
449
+ In this International Standard, the notation cv (or *cv1*, *cv2*, etc.),
450
+ used in the description of types, represents an arbitrary set of
451
  cv-qualifiers, i.e., one of {`const`}, {`volatile`}, {`const`,
452
+ `volatile`}, or the empty set. For a type cv `T`, the *top-level
453
+ cv-qualifiers* of that type are those denoted by cv.
454
+
455
+ [*Example 1*: The type corresponding to the *type-id* `const int&` has
456
+ no top-level cv-qualifiers. The type corresponding to the *type-id*
457
+ `volatile int * const` has the top-level cv-qualifier `const`. For a
458
+ class type `C`, the type corresponding to the *type-id*
459
+ `void (C::* volatile)(int) const` has the top-level cv-qualifier
460
+ `volatile`. — *end example*]
461
+
462
+ Cv-qualifiers applied to an array type attach to the underlying element
463
+ type, so the notation “cv `T`”, where `T` is an array type, refers to an
464
+ array whose elements are so-qualified. An array type whose elements are
465
+ cv-qualified is also considered to have the same cv-qualifications as
466
+ its elements.
467
+
468
+ [*Example 2*:
469
 
470
  ``` cpp
471
  typedef char CA[5];
472
  typedef const char CC;
473
  CC arr1[5] = { 0 };
474
  const CA arr2 = { 0 };
475
  ```
476
 
477
+ The type of both `arr1` and `arr2` is “array of 5 `const char`”, and the
478
+ array type is considered to be const-qualified.
479
+
480
+ — *end example*]
481