From Jason Turner

[expr.const]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpctanqfvt/{from.md → to.md} +430 -207
tmp/tmpctanqfvt/{from.md → to.md} RENAMED
@@ -2,127 +2,163 @@
2
 
3
  Certain contexts require expressions that satisfy additional
4
  requirements as detailed in this subclause; other contexts have
5
  different semantics depending on whether or not an expression satisfies
6
  these requirements. Expressions that satisfy these requirements,
7
- assuming that copy elision is performed, are called *constant
8
- expressions*.
9
 
10
  [*Note 1*: Constant expressions can be evaluated during
11
  translation. — *end note*]
12
 
13
  ``` bnf
14
  constant-expression:
15
  conditional-expression
16
  ```
17
 
18
- An expression `e` is a *core constant expression* unless the evaluation
19
- of `e`, following the rules of the abstract machine (
20
- [[intro.execution]]), would evaluate one of the following expressions:
21
-
22
- - `this` ([[expr.prim.this]]), except in a constexpr function or a
23
- constexpr constructor that is being evaluated as part of `e`;
24
- - an invocation of a function other than a constexpr constructor for a
25
- literal class, a constexpr function, or an implicit invocation of a
26
- trivial destructor ([[class.dtor]]) \[*Note 2*: Overload resolution (
27
- [[over.match]]) is applied as usual — *end note*] ;
28
- - an invocation of an undefined constexpr function or an undefined
29
- constexpr constructor;
30
- - an invocation of an instantiated constexpr function or constexpr
31
- constructor that fails to satisfy the requirements for a constexpr
32
- function or constexpr constructor ([[dcl.constexpr]]);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33
  - an expression that would exceed the implementation-defined limits (see
34
- Annex  [[implimits]]);
35
  - an operation that would have undefined behavior as specified in
36
- Clauses  [[intro]] through  [[cpp]] of this International Standard
37
- \[*Note 3*: including, for example, signed integer overflow (Clause
38
- [[expr]]), certain pointer arithmetic ([[expr.add]]), division by
39
- zero ([[expr.mul]]), or certain shift operations (
40
- [[expr.shift]]) *end note*] ;
41
- - an lvalue-to-rvalue conversion ([[conv.lval]]) unless it is applied
42
- to
43
- - a non-volatile glvalue of integral or enumeration type that refers
44
- to a complete non-volatile const object with a preceding
45
- initialization, initialized with a constant expression, or
46
- - a non-volatile glvalue that refers to a subobject of a string
47
- literal ([[lex.string]]), or
48
- - a non-volatile glvalue that refers to a non-volatile object defined
49
- with `constexpr`, or that refers to a non-mutable subobject of such
50
- an object, or
51
  - a non-volatile glvalue of literal type that refers to a non-volatile
52
- object whose lifetime began within the evaluation of `e`;
53
- - an lvalue-to-rvalue conversion ([[conv.lval]]) that is applied to a
54
  glvalue that refers to a non-active member of a union or a subobject
55
  thereof;
 
 
56
  - an invocation of an implicitly-defined copy/move constructor or
57
  copy/move assignment operator for a union whose active member (if any)
58
  is mutable, unless the lifetime of the union object began within the
59
- evaluation of `e`;
60
- - an assignment expression ([[expr.ass]]) or invocation of an
61
- assignment operator ([[class.copy]]) that would change the active
62
- member of a union;
63
  - an *id-expression* that refers to a variable or data member of
64
  reference type unless the reference has a preceding initialization and
65
  either
66
- - it is initialized with a constant expression or
67
- - its lifetime began within the evaluation of `e`;
68
  - in a *lambda-expression*, a reference to `this` or to a variable with
69
  automatic storage duration defined outside that *lambda-expression*,
70
  where the reference would be an odr-use ([[basic.def.odr]],
71
  [[expr.prim.lambda]]);
72
  \[*Example 1*:
73
  ``` cpp
74
  void g() {
75
  const int n = 0;
76
  [=] {
77
- constexpr int i = n; // OK, n is not odr-used and not captured here
78
- constexpr int j = *&n; // ill-formed, &n would be an odr-use of n
79
  };
80
  }
81
  ```
82
 
83
  — *end example*]
84
- \[*Note 4*:
85
  If the odr-use occurs in an invocation of a function call operator of
86
  a closure type, it no longer refers to `this` or to an enclosing
87
- automatic variable due to the transformation (
88
- [[expr.prim.lambda.capture]]) of the *id-expression* into an access of
89
  the corresponding data member.
90
  \[*Example 2*:
91
  ``` cpp
92
  auto monad = [](auto v) { return [=] { return v; }; };
93
  auto bind = [](auto m) {
94
  return [=](auto fvm) { return fvm(m()); };
95
  };
96
 
97
- // OK to have captures to automatic objects created during constant expression evaluation.
98
  static_assert(bind(monad(2))(monad)() == monad(2)());
99
  ```
100
 
101
  — *end example*]
102
  — *end note*]
103
  - a conversion from type cv `void*` to a pointer-to-object type;
104
- - a dynamic cast ([[expr.dynamic.cast]]);
105
- - a `reinterpret_cast` ([[expr.reinterpret.cast]]);
106
- - a pseudo-destructor call ([[expr.pseudo]]);
107
- - modification of an object ([[expr.ass]], [[expr.post.incr]],
108
  [[expr.pre.incr]]) unless it is applied to a non-volatile lvalue of
109
  literal type that refers to a non-volatile object whose lifetime began
110
- within the evaluation of `e`;
111
- - a typeid expression ([[expr.typeid]]) whose operand is a glvalue of a
112
- polymorphic class type;
113
- - a *new-expression* ([[expr.new]]);
114
- - a *delete-expression* ([[expr.delete]]);
115
- - a relational ([[expr.rel]]) or equality ([[expr.eq]]) operator where
116
- the result is unspecified; or
117
- - a *throw-expression* ([[expr.throw]]).
 
 
 
 
 
 
 
 
 
 
 
 
 
 
118
 
119
- If `e` satisfies the constraints of a core constant expression, but
120
- evaluation of `e` would evaluate an operation that has undefined
121
- behavior as specified in Clauses  [[library]] through  [[thread]] of
122
- this International Standard, it is unspecified whether `e` is a core
123
- constant expression.
124
 
125
  [*Example 3*:
126
 
127
  ``` cpp
128
  int x; // not constant
@@ -162,47 +198,101 @@ constexpr int y = h(1); // OK: initializes y with the value 2
162
  // the lifetime of k begins inside h(1)
163
  ```
164
 
165
  — *end example*]
166
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
167
  An *integral constant expression* is an expression of integral or
168
  unscoped enumeration type, implicitly converted to a prvalue, where the
169
  converted expression is a core constant expression.
170
 
171
- [*Note 5*: Such expressions may be used as bit-field lengths (
172
- [[class.bit]]), as enumerator initializers if the underlying type is not
173
- fixed ([[dcl.enum]]), and as alignments (
174
- [[dcl.align]]). — *end note*]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
175
 
176
  A *converted constant expression* of type `T` is an expression,
177
  implicitly converted to type `T`, where the converted expression is a
178
  constant expression and the implicit conversion sequence contains only
179
 
180
  - user-defined conversions,
181
- - lvalue-to-rvalue conversions ([[conv.lval]]),
182
- - array-to-pointer conversions ([[conv.array]]),
183
- - function-to-pointer conversions ([[conv.func]]),
184
- - qualification conversions ([[conv.qual]]),
185
- - integral promotions ([[conv.prom]]),
186
- - integral conversions ([[conv.integral]]) other than narrowing
187
- conversions ([[dcl.init.list]]),
188
- - null pointer conversions ([[conv.ptr]]) from `std::nullptr_t`,
189
- - null member pointer conversions ([[conv.mem]]) from `std::nullptr_t`,
190
  and
191
- - function pointer conversions ([[conv.fctptr]]),
192
 
193
  and where the reference binding (if any) binds directly.
194
 
195
- [*Note 6*: Such expressions may be used in `new` expressions (
196
- [[expr.new]]), as case expressions ([[stmt.switch]]), as enumerator
197
- initializers if the underlying type is fixed ([[dcl.enum]]), as array
198
- bounds ([[dcl.array]]), and as non-type template arguments (
199
- [[temp.arg]]). — *end note*]
200
 
201
  A *contextually converted constant expression of type `bool`* is an
202
- expression, contextually converted to `bool` (Clause [[conv]]), where
203
- the converted expression is a constant expression and the conversion
204
  sequence contains only the conversions above.
205
 
206
  A *constant expression* is either a glvalue core constant expression
207
  that refers to an entity that is a permitted result of a constant
208
  expression (as defined below), or a prvalue core constant expression
@@ -211,29 +301,44 @@ whose value satisfies the following constraints:
211
  - if the value is an object of class type, each non-static data member
212
  of reference type refers to an entity that is a permitted result of a
213
  constant expression,
214
  - if the value is of pointer type, it contains the address of an object
215
  with static storage duration, the address past the end of such an
216
- object ([[expr.add]]), the address of a function, or a null pointer
217
- value, and
 
 
218
  - if the value is an object of class or array type, each subobject
219
  satisfies these constraints for the value.
220
 
221
  An entity is a *permitted result of a constant expression* if it is an
222
- object with static storage duration that is either not a temporary
223
  object or is a temporary object whose value satisfies the above
224
- constraints, or it is a function.
225
 
226
- [*Note 7*:
227
 
228
- Since this International Standard imposes no restrictions on the
229
- accuracy of floating-point operations, it is unspecified whether the
230
- evaluation of a floating-point expression during translation yields the
231
- same result as the evaluation of the same expression (or the same
232
- operations on the same values) during program execution.[^28]
 
 
 
233
 
234
- [*Example 4*:
 
 
 
 
 
 
 
 
 
 
235
 
236
  ``` cpp
237
  bool f() {
238
  char array[1 + int(1 + 0.2 - 0.1 - 0.1)]; // Must be evaluated during translation
239
  int size = 1 + int(1 + 0.2 - 0.1 - 0.1); // May be evaluated at runtime
@@ -245,48 +350,88 @@ It is unspecified whether the value of `f()` will be `true` or `false`.
245
 
246
  — *end example*]
247
 
248
  — *end note*]
249
 
250
- If an expression of literal class type is used in a context where an
251
- integral constant expression is required, then that expression is
252
- contextually implicitly converted (Clause  [[conv]]) to an integral or
253
- unscoped enumeration type and the selected conversion function shall be
254
- `constexpr`.
 
 
255
 
256
- [*Example 5*:
257
 
 
 
 
 
 
 
 
 
258
  ``` cpp
259
- struct A {
260
- constexpr A(int i) : val(i) { }
261
- constexpr operator int() const { return val; }
262
- constexpr operator long() const { return 43; }
263
- private:
264
- int val;
265
- };
266
- template<int> struct X { };
267
- constexpr A a = 42;
268
- X<a> x; // OK: unique conversion to int
269
- int ary[a]; // error: ambiguous conversion
 
 
 
 
 
 
270
  ```
271
 
272
  — *end example*]
273
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
274
  <!-- Link reference definitions -->
275
- [bad.alloc]: language.md#bad.alloc
276
- [bad.cast]: language.md#bad.cast
277
- [bad.typeid]: language.md#bad.typeid
 
278
  [basic.align]: basic.md#basic.align
279
  [basic.compound]: basic.md#basic.compound
280
  [basic.def.odr]: basic.md#basic.def.odr
281
  [basic.fundamental]: basic.md#basic.fundamental
 
282
  [basic.life]: basic.md#basic.life
283
  [basic.lookup]: basic.md#basic.lookup
284
  [basic.lookup.argdep]: basic.md#basic.lookup.argdep
285
  [basic.lookup.classref]: basic.md#basic.lookup.classref
286
  [basic.lookup.unqual]: basic.md#basic.lookup.unqual
287
- [basic.lval]: basic.md#basic.lval
288
  [basic.namespace]: dcl.md#basic.namespace
289
  [basic.scope.block]: basic.md#basic.scope.block
290
  [basic.scope.class]: basic.md#basic.scope.class
291
  [basic.start.main]: basic.md#basic.start.main
292
  [basic.stc.dynamic]: basic.md#basic.stc.dynamic
@@ -297,87 +442,111 @@ int ary[a]; // error: ambiguous conversion
297
  [basic.types]: basic.md#basic.types
298
  [class]: class.md#class
299
  [class.abstract]: class.md#class.abstract
300
  [class.access]: class.md#class.access
301
  [class.access.base]: class.md#class.access.base
302
- [class.base.init]: special.md#class.base.init
303
  [class.bit]: class.md#class.bit
304
- [class.cdtor]: special.md#class.cdtor
305
- [class.conv]: special.md#class.conv
306
- [class.conv.fct]: special.md#class.conv.fct
307
- [class.copy]: special.md#class.copy
308
- [class.ctor]: special.md#class.ctor
 
 
309
  [class.derived]: class.md#class.derived
310
- [class.dtor]: special.md#class.dtor
311
- [class.free]: special.md#class.free
312
  [class.friend]: class.md#class.friend
313
- [class.init]: special.md#class.init
314
  [class.mem]: class.md#class.mem
315
  [class.member.lookup]: class.md#class.member.lookup
316
  [class.mfct]: class.md#class.mfct
317
  [class.mfct.non-static]: class.md#class.mfct.non-static
318
- [class.name]: class.md#class.name
 
319
  [class.qual]: basic.md#class.qual
 
320
  [class.static]: class.md#class.static
321
- [class.temporary]: special.md#class.temporary
322
  [class.this]: class.md#class.this
323
  [class.union]: class.md#class.union
324
  [class.virtual]: class.md#class.virtual
325
- [conv]: conv.md#conv
326
- [conv.array]: conv.md#conv.array
327
- [conv.bool]: conv.md#conv.bool
328
- [conv.fctptr]: conv.md#conv.fctptr
329
- [conv.fpint]: conv.md#conv.fpint
330
- [conv.fpprom]: conv.md#conv.fpprom
331
- [conv.func]: conv.md#conv.func
332
- [conv.integral]: conv.md#conv.integral
333
- [conv.lval]: conv.md#conv.lval
334
- [conv.mem]: conv.md#conv.mem
335
- [conv.prom]: conv.md#conv.prom
336
- [conv.ptr]: conv.md#conv.ptr
337
- [conv.qual]: conv.md#conv.qual
338
- [conv.rval]: conv.md#conv.rval
 
 
 
339
  [cpp]: cpp.md#cpp
340
- [cstddef.syn]: language.md#cstddef.syn
 
341
  [dcl.align]: dcl.md#dcl.align
342
  [dcl.array]: dcl.md#dcl.array
 
343
  [dcl.constexpr]: dcl.md#dcl.constexpr
344
  [dcl.dcl]: dcl.md#dcl.dcl
 
345
  [dcl.enum]: dcl.md#dcl.enum
346
  [dcl.fct]: dcl.md#dcl.fct
347
  [dcl.fct.def]: dcl.md#dcl.fct.def
 
348
  [dcl.fct.def.general]: dcl.md#dcl.fct.def.general
349
  [dcl.fct.default]: dcl.md#dcl.fct.default
350
  [dcl.init]: dcl.md#dcl.init
351
  [dcl.init.aggr]: dcl.md#dcl.init.aggr
352
  [dcl.init.list]: dcl.md#dcl.init.list
353
  [dcl.init.ref]: dcl.md#dcl.init.ref
 
354
  [dcl.link]: dcl.md#dcl.link
 
355
  [dcl.name]: dcl.md#dcl.name
 
356
  [dcl.ref]: dcl.md#dcl.ref
357
  [dcl.spec.auto]: dcl.md#dcl.spec.auto
358
  [dcl.stc]: dcl.md#dcl.stc
359
  [dcl.struct.bind]: dcl.md#dcl.struct.bind
360
  [dcl.type]: dcl.md#dcl.type
361
  [dcl.type.cv]: dcl.md#dcl.type.cv
362
  [dcl.type.simple]: dcl.md#dcl.type.simple
 
 
 
 
 
 
363
  [except]: except.md#except
364
  [except.handle]: except.md#except.handle
 
365
  [except.spec]: except.md#except.spec
366
  [except.terminate]: except.md#except.terminate
367
  [except.throw]: except.md#except.throw
368
  [expr]: #expr
369
  [expr.add]: #expr.add
370
  [expr.alignof]: #expr.alignof
 
371
  [expr.ass]: #expr.ass
 
372
  [expr.bit.and]: #expr.bit.and
373
  [expr.call]: #expr.call
374
  [expr.cast]: #expr.cast
375
  [expr.comma]: #expr.comma
 
376
  [expr.cond]: #expr.cond
377
  [expr.const]: #expr.const
378
  [expr.const.cast]: #expr.const.cast
 
379
  [expr.delete]: #expr.delete
380
  [expr.dynamic.cast]: #expr.dynamic.cast
381
  [expr.eq]: #expr.eq
382
  [expr.log.and]: #expr.log.and
383
  [expr.log.or]: #expr.log.or
@@ -385,51 +554,64 @@ int ary[a]; // error: ambiguous conversion
385
  [expr.mul]: #expr.mul
386
  [expr.new]: #expr.new
387
  [expr.or]: #expr.or
388
  [expr.post]: #expr.post
389
  [expr.post.incr]: #expr.post.incr
 
390
  [expr.pre.incr]: #expr.pre.incr
391
  [expr.prim]: #expr.prim
392
  [expr.prim.fold]: #expr.prim.fold
393
  [expr.prim.id]: #expr.prim.id
 
394
  [expr.prim.id.qual]: #expr.prim.id.qual
395
  [expr.prim.id.unqual]: #expr.prim.id.unqual
396
  [expr.prim.lambda]: #expr.prim.lambda
397
  [expr.prim.lambda.capture]: #expr.prim.lambda.capture
398
  [expr.prim.lambda.closure]: #expr.prim.lambda.closure
399
  [expr.prim.literal]: #expr.prim.literal
400
  [expr.prim.paren]: #expr.prim.paren
 
 
 
 
 
401
  [expr.prim.this]: #expr.prim.this
402
- [expr.pseudo]: #expr.pseudo
403
  [expr.ref]: #expr.ref
404
  [expr.reinterpret.cast]: #expr.reinterpret.cast
405
  [expr.rel]: #expr.rel
406
  [expr.shift]: #expr.shift
407
  [expr.sizeof]: #expr.sizeof
 
408
  [expr.static.cast]: #expr.static.cast
409
  [expr.sub]: #expr.sub
410
  [expr.throw]: #expr.throw
 
411
  [expr.type.conv]: #expr.type.conv
412
  [expr.typeid]: #expr.typeid
413
  [expr.unary]: #expr.unary
414
  [expr.unary.noexcept]: #expr.unary.noexcept
415
  [expr.unary.op]: #expr.unary.op
416
  [expr.xor]: #expr.xor
 
417
  [function.objects]: utilities.md#function.objects
418
  [implimits]: limits.md#implimits
419
  [intro]: intro.md#intro
420
- [intro.execution]: intro.md#intro.execution
421
- [intro.memory]: intro.md#intro.memory
422
- [intro.object]: intro.md#intro.object
 
 
423
  [lex.literal]: lex.md#lex.literal
424
  [lex.string]: lex.md#lex.string
425
  [library]: library.md#library
 
426
  [namespace.qual]: basic.md#namespace.qual
427
- [new.badlength]: language.md#new.badlength
428
- [new.delete.array]: language.md#new.delete.array
429
- [new.delete.placement]: language.md#new.delete.placement
430
- [new.delete.single]: language.md#new.delete.single
431
  [over]: over.md#over
432
  [over.ass]: over.md#over.ass
433
  [over.best.ics]: over.md#over.best.ics
434
  [over.built]: over.md#over.built
435
  [over.call]: over.md#over.call
@@ -440,121 +622,162 @@ int ary[a]; // error: ambiguous conversion
440
  [over.match.oper]: over.md#over.match.oper
441
  [over.match.viable]: over.md#over.match.viable
442
  [over.oper]: over.md#over.oper
443
  [over.over]: over.md#over.over
444
  [replacement.functions]: library.md#replacement.functions
 
 
 
 
445
  [stmt.return]: stmt.md#stmt.return
446
  [stmt.switch]: stmt.md#stmt.switch
447
- [support.runtime]: language.md#support.runtime
448
- [support.types]: language.md#support.types
449
- [support.types.layout]: language.md#support.types.layout
450
  [temp.arg]: temp.md#temp.arg
 
 
 
 
 
451
  [temp.expl.spec]: temp.md#temp.expl.spec
452
  [temp.explicit]: temp.md#temp.explicit
453
- [temp.mem]: temp.md#temp.mem
454
  [temp.names]: temp.md#temp.names
 
 
455
  [temp.res]: temp.md#temp.res
456
  [temp.variadic]: temp.md#temp.variadic
457
  [thread]: thread.md#thread
458
- [type.info]: language.md#type.info
459
 
460
  [^1]: The precedence of operators is not directly specified, but it can
461
  be derived from the syntax.
462
 
463
- [^2]: As a consequence, operands of type `bool`, `char16_t`, `char32_t`,
464
- `wchar_t`, or an enumerated type are converted to some integral
465
- type.
466
 
467
  [^3]: The cast and assignment operators must still perform their
468
- specific conversions as described in  [[expr.cast]], 
469
- [[expr.static.cast]] and  [[expr.ass]].
470
 
471
- [^4]: This also applies when the object expression is an implicit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
472
  `(*this)` ([[class.mfct.non-static]]).
473
 
474
- [^5]: This is true even if the subscript operator is used in the
475
  following common idiom: `&x[0]`.
476
 
477
- [^6]: If the class member access expression is evaluated, the
478
  subexpression evaluation happens even if the result is unnecessary
479
  to determine the value of the entire postfix expression, for example
480
  if the *id-expression* denotes a static member.
481
 
482
- [^7]: Note that `(*(E1))` is an lvalue.
483
 
484
- [^8]: The most derived object ([[intro.object]]) pointed or referred to
485
  by `v` can contain other `B` objects as base classes, but these are
486
  ignored.
487
 
488
- [^9]: The recommended name for such a class is `extended_type_info`.
489
 
490
- [^10]: If `p` is an expression of pointer type, then `*p`, `(*p)`,
491
  `*(p)`, `((*p))`, `*((p))`, and so on all meet this requirement.
492
 
493
- [^11]: Function types (including those used in pointer to member
494
- function types) are never cv-qualified; see  [[dcl.fct]].
495
-
496
- [^12]: The types may have different cv-qualifiers, subject to the
497
  overall restriction that a `reinterpret_cast` cannot cast away
498
  constness.
499
 
500
- [^13]: `T1` and `T2` may have different cv-qualifiers, subject to the
501
  overall restriction that a `reinterpret_cast` cannot cast away
502
  constness.
503
 
504
- [^14]: This is sometimes referred to as a *type pun*.
 
505
 
506
- [^15]: `const_cast`
507
 
508
  is not limited to conversions that cast away a const-qualifier.
509
 
510
- [^16]: `sizeof(bool)` is not required to be `1`.
511
 
512
- [^17]: The actual size of a base class subobject may be less than the
513
- result of applying `sizeof` to the subobject, due to virtual base
514
- classes and less strict padding requirements on base class
515
- subobjects.
516
 
517
- [^18]: If the conversion function returns a signed integer type, the
518
  second standard conversion converts to the unsigned type
519
  `std::size_t` and thus thwarts any attempt to detect a negative
520
  value afterwards.
521
 
522
- [^19]: This may include evaluating a *new-initializer* and/or calling a
523
  constructor.
524
 
525
- [^20]: A lambda expression with a *lambda-introducer* that consists of
526
- empty square brackets can follow the `delete` keyword if the lambda
527
- expression is enclosed in parentheses.
528
 
529
- [^21]: This implies that an object cannot be deleted using a pointer of
530
  type `void*` because `void` is not an object type.
531
 
532
- [^22]: For nonzero-length arrays, this is the same as a pointer to the
533
  first element of the array created by that *new-expression*.
534
  Zero-length arrays do not have a first element.
535
 
536
- [^23]: If the static type of the object to be deleted is complete and is
537
- different from the dynamic type, and the destructor is not virtual,
538
- the size might be incorrect, but that case is already undefined, as
539
- stated above.
540
 
541
- [^24]: This is often called truncation towards zero.
 
 
 
 
542
 
543
- [^25]: An object that is not an array element is considered to belong to
544
- a single-element array for this purpose; see  [[expr.unary.op]]. A
545
- pointer past the last element of an array `x` of n elements is
546
- considered to be equivalent to a pointer to a hypothetical element
547
- x[n] for this purpose; see  [[basic.compound]].
548
 
549
- [^26]: An object that is not an array element is considered to belong to
550
- a single-element array for this purpose; see  [[expr.unary.op]]. A
551
- pointer past the last element of an array `x` of n elements is
552
- considered to be equivalent to a pointer to a hypothetical element
553
- x[n] for this purpose; see  [[basic.compound]].
554
 
555
- [^27]: An object that is not an array element is considered to belong to
556
- a single-element array for this purpose; see  [[expr.unary.op]].
557
-
558
- [^28]: Nonetheless, implementations are encouraged to provide consistent
559
- results, irrespective of whether the evaluation was performed during
560
  translation and/or during program execution.
 
 
 
 
 
 
 
 
 
 
2
 
3
  Certain contexts require expressions that satisfy additional
4
  requirements as detailed in this subclause; other contexts have
5
  different semantics depending on whether or not an expression satisfies
6
  these requirements. Expressions that satisfy these requirements,
7
+ assuming that copy elision [[class.copy.elision]] is not performed, are
8
+ called *constant expressions*.
9
 
10
  [*Note 1*: Constant expressions can be evaluated during
11
  translation. — *end note*]
12
 
13
  ``` bnf
14
  constant-expression:
15
  conditional-expression
16
  ```
17
 
18
+ A variable or temporary object `o` is *constant-initialized* if
19
+
20
+ - either it has an initializer or its default-initialization results in
21
+ some initialization being performed, and
22
+ - the full-expression of its initialization is a constant expression
23
+ when interpreted as a *constant-expression*, except that if `o` is an
24
+ object, that full-expression may also invoke constexpr constructors
25
+ for `o` and its subobjects even if those objects are of non-literal
26
+ class types. \[*Note 2*: Such a class may have a non-trivial
27
+ destructor. Within this evaluation, `std::is_constant_evaluated()`
28
+ [[meta.const.eval]] returns `true`. *end note*]
29
+
30
+ A variable is *potentially-constant* if it is constexpr or it has
31
+ reference or const-qualified integral or enumeration type.
32
+
33
+ A constant-initialized potentially-constant variable is *usable in
34
+ constant expressions* at a point P if its initializing declaration D is
35
+ reachable from P and
36
+
37
+ - it is constexpr,
38
+ - it is not initialized to a TU-local value, or
39
+ - P is in the same translation unit as D.
40
+
41
+ An object or reference is *usable in constant expressions* if it is
42
+
43
+ - a variable that is usable in constant expressions, or
44
+ - a template parameter object [[temp.param]], or
45
+ - a string literal object [[lex.string]], or
46
+ - a temporary object of non-volatile const-qualified literal type whose
47
+ lifetime is extended [[class.temporary]] to that of a variable that is
48
+ usable in constant expressions, or
49
+ - a non-mutable subobject or reference member of any of the above.
50
+
51
+ An expression E is a *core constant expression* unless the evaluation of
52
+ E, following the rules of the abstract machine [[intro.execution]],
53
+ would evaluate one of the following:
54
+
55
+ - `this` [[expr.prim.this]], except in a constexpr function
56
+ [[dcl.constexpr]] that is being evaluated as part of E;
57
+ - an invocation of a non-constexpr function \[*Note 3*: Overload
58
+ resolution [[over.match]] is applied as usual. — *end note*] ;
59
+ - an invocation of an undefined constexpr function;
60
+ - an invocation of an instantiated constexpr function that fails to
61
+ satisfy the requirements for a constexpr function;
62
+ - an invocation of a virtual function [[class.virtual]] for an object
63
+ unless
64
+ - the object is usable in constant expressions or
65
+ - its lifetime began within the evaluation of E;
66
  - an expression that would exceed the implementation-defined limits (see
67
+ [[implimits]]);
68
  - an operation that would have undefined behavior as specified in
69
+ [[intro]] through [[cpp]] of this document \[*Note 4*: including, for
70
+ example, signed integer overflow [[expr.prop]], certain pointer
71
+ arithmetic [[expr.add]], division by zero [[expr.mul]], or certain
72
+ shift operations [[expr.shift]] *end note*] ;
73
+ - an lvalue-to-rvalue conversion [[conv.lval]] unless it is applied to
74
+ - a non-volatile glvalue that refers to an object that is usable in
75
+ constant expressions, or
 
 
 
 
 
 
 
 
76
  - a non-volatile glvalue of literal type that refers to a non-volatile
77
+ object whose lifetime began within the evaluation of E;
78
+ - an lvalue-to-rvalue conversion [[conv.lval]] that is applied to a
79
  glvalue that refers to a non-active member of a union or a subobject
80
  thereof;
81
+ - an lvalue-to-rvalue conversion that is applied to an object with an
82
+ indeterminate value [[basic.indet]];
83
  - an invocation of an implicitly-defined copy/move constructor or
84
  copy/move assignment operator for a union whose active member (if any)
85
  is mutable, unless the lifetime of the union object began within the
86
+ evaluation of E;
 
 
 
87
  - an *id-expression* that refers to a variable or data member of
88
  reference type unless the reference has a preceding initialization and
89
  either
90
+ - it is usable in constant expressions or
91
+ - its lifetime began within the evaluation of E;
92
  - in a *lambda-expression*, a reference to `this` or to a variable with
93
  automatic storage duration defined outside that *lambda-expression*,
94
  where the reference would be an odr-use ([[basic.def.odr]],
95
  [[expr.prim.lambda]]);
96
  \[*Example 1*:
97
  ``` cpp
98
  void g() {
99
  const int n = 0;
100
  [=] {
101
+ constexpr int i = n; // OK, n is not odr-used here
102
+ constexpr int j = *&n; // error: &n would be an odr-use of n
103
  };
104
  }
105
  ```
106
 
107
  — *end example*]
108
+ \[*Note 5*:
109
  If the odr-use occurs in an invocation of a function call operator of
110
  a closure type, it no longer refers to `this` or to an enclosing
111
+ automatic variable due to the transformation
112
+ [[expr.prim.lambda.capture]] of the *id-expression* into an access of
113
  the corresponding data member.
114
  \[*Example 2*:
115
  ``` cpp
116
  auto monad = [](auto v) { return [=] { return v; }; };
117
  auto bind = [](auto m) {
118
  return [=](auto fvm) { return fvm(m()); };
119
  };
120
 
121
+ // OK to capture objects with automatic storage duration created during constant expression evaluation.
122
  static_assert(bind(monad(2))(monad)() == monad(2)());
123
  ```
124
 
125
  — *end example*]
126
  — *end note*]
127
  - a conversion from type cv `void*` to a pointer-to-object type;
128
+ - a `reinterpret_cast` [[expr.reinterpret.cast]];
129
+ - a modification of an object ([[expr.ass]], [[expr.post.incr]],
 
 
130
  [[expr.pre.incr]]) unless it is applied to a non-volatile lvalue of
131
  literal type that refers to a non-volatile object whose lifetime began
132
+ within the evaluation of E;
133
+ - a *new-expression* [[expr.new]], unless the selected allocation
134
+ function is a replaceable global allocation function (
135
+ [[new.delete.single]], [[new.delete.array]]) and the allocated storage
136
+ is deallocated within the evaluation of E;
137
+ - a *delete-expression* [[expr.delete]], unless it deallocates a region
138
+ of storage allocated within the evaluation of E;
139
+ - a call to an instance of `std::allocator<T>::allocate`
140
+ [[allocator.members]], unless the allocated storage is deallocated
141
+ within the evaluation of E;
142
+ - a call to an instance of `std::allocator<T>::deallocate`
143
+ [[allocator.members]], unless it deallocates a region of storage
144
+ allocated within the evaluation of E;
145
+ - an *await-expression* [[expr.await]];
146
+ - a *yield-expression* [[expr.yield]];
147
+ - a three-way comparison [[expr.spaceship]], relational [[expr.rel]], or
148
+ equality [[expr.eq]] operator where the result is unspecified;
149
+ - a *throw-expression* [[expr.throw]] or a dynamic cast
150
+ [[expr.dynamic.cast]] or `typeid` [[expr.typeid]] expression that
151
+ would throw an exception;
152
+ - an *asm-declaration* [[dcl.asm]]; or
153
+ - an invocation of the `va_arg` macro [[cstdarg.syn]].
154
 
155
+ If E satisfies the constraints of a core constant expression, but
156
+ evaluation of E would evaluate an operation that has undefined behavior
157
+ as specified in [[library]] through [[thread]] of this document, or an
158
+ invocation of the `va_start` macro [[cstdarg.syn]], it is unspecified
159
+ whether E is a core constant expression.
160
 
161
  [*Example 3*:
162
 
163
  ``` cpp
164
  int x; // not constant
 
198
  // the lifetime of k begins inside h(1)
199
  ```
200
 
201
  — *end example*]
202
 
203
+ For the purposes of determining whether an expression E is a core
204
+ constant expression, the evaluation of a call to a member function of
205
+ `std::allocator<T>` as defined in [[allocator.members]], where `T` is a
206
+ literal type, does not disqualify E from being a core constant
207
+ expression, even if the actual evaluation of such a call would otherwise
208
+ fail the requirements for a core constant expression. Similarly, the
209
+ evaluation of a call to `std::destroy_at`, `std::ranges::destroy_at`,
210
+ `std::construct_at`, or `std::ranges::construct_at` does not disqualify
211
+ E from being a core constant expression unless:
212
+
213
+ - for a call to `std::construct_at` or `std::ranges::construct_at`, the
214
+ first argument, of type `T*`, does not point to storage allocated with
215
+ `std::allocator<T>` or to an object whose lifetime began within the
216
+ evaluation of E, or the evaluation of the underlying constructor call
217
+ disqualifies E from being a core constant expression, or
218
+ - for a call to `std::destroy_at` or `std::ranges::destroy_at`, the
219
+ first argument, of type `T*`, does not point to storage allocated with
220
+ `std::allocator<T>` or to an object whose lifetime began within the
221
+ evaluation of E, or the evaluation of the underlying destructor call
222
+ disqualifies E from being a core constant expression.
223
+
224
+ An object `a` is said to have *constant destruction* if:
225
+
226
+ - it is not of class type nor (possibly multi-dimensional) array
227
+ thereof, or
228
+ - it is of class type or (possibly multi-dimensional) array thereof,
229
+ that class type has a constexpr destructor, and for a hypothetical
230
+ expression E whose only effect is to destroy `a`, E would be a core
231
+ constant expression if the lifetime of `a` and its non-mutable
232
+ subobjects (but not its mutable subobjects) were considered to start
233
+ within E.
234
+
235
  An *integral constant expression* is an expression of integral or
236
  unscoped enumeration type, implicitly converted to a prvalue, where the
237
  converted expression is a core constant expression.
238
 
239
+ [*Note 6*: Such expressions may be used as bit-field lengths
240
+ [[class.bit]], as enumerator initializers if the underlying type is not
241
+ fixed [[dcl.enum]], and as alignments [[dcl.align]]. — *end note*]
242
+
243
+ If an expression of literal class type is used in a context where an
244
+ integral constant expression is required, then that expression is
245
+ contextually implicitly converted [[conv]] to an integral or unscoped
246
+ enumeration type and the selected conversion function shall be
247
+ `constexpr`.
248
+
249
+ [*Example 4*:
250
+
251
+ ``` cpp
252
+ struct A {
253
+ constexpr A(int i) : val(i) { }
254
+ constexpr operator int() const { return val; }
255
+ constexpr operator long() const { return 42; }
256
+ private:
257
+ int val;
258
+ };
259
+ constexpr A a = alignof(int);
260
+ alignas(a) int n; // error: ambiguous conversion
261
+ struct B { int n : a; }; // error: ambiguous conversion
262
+ ```
263
+
264
+ — *end example*]
265
 
266
  A *converted constant expression* of type `T` is an expression,
267
  implicitly converted to type `T`, where the converted expression is a
268
  constant expression and the implicit conversion sequence contains only
269
 
270
  - user-defined conversions,
271
+ - lvalue-to-rvalue conversions [[conv.lval]],
272
+ - array-to-pointer conversions [[conv.array]],
273
+ - function-to-pointer conversions [[conv.func]],
274
+ - qualification conversions [[conv.qual]],
275
+ - integral promotions [[conv.prom]],
276
+ - integral conversions [[conv.integral]] other than narrowing
277
+ conversions [[dcl.init.list]],
278
+ - null pointer conversions [[conv.ptr]] from `std::nullptr_t`,
279
+ - null member pointer conversions [[conv.mem]] from `std::nullptr_t`,
280
  and
281
+ - function pointer conversions [[conv.fctptr]],
282
 
283
  and where the reference binding (if any) binds directly.
284
 
285
+ [*Note 7*: Such expressions may be used in `new` expressions
286
+ [[expr.new]], as case expressions [[stmt.switch]], as enumerator
287
+ initializers if the underlying type is fixed [[dcl.enum]], as array
288
+ bounds [[dcl.array]], and as non-type template arguments
289
+ [[temp.arg]]. — *end note*]
290
 
291
  A *contextually converted constant expression of type `bool`* is an
292
+ expression, contextually converted to `bool` [[conv]], where the
293
+ converted expression is a constant expression and the conversion
294
  sequence contains only the conversions above.
295
 
296
  A *constant expression* is either a glvalue core constant expression
297
  that refers to an entity that is a permitted result of a constant
298
  expression (as defined below), or a prvalue core constant expression
 
301
  - if the value is an object of class type, each non-static data member
302
  of reference type refers to an entity that is a permitted result of a
303
  constant expression,
304
  - if the value is of pointer type, it contains the address of an object
305
  with static storage duration, the address past the end of such an
306
+ object [[expr.add]], the address of a non-immediate function, or a
307
+ null pointer value,
308
+ - if the value is of pointer-to-member-function type, it does not
309
+ designate an immediate function, and
310
  - if the value is an object of class or array type, each subobject
311
  satisfies these constraints for the value.
312
 
313
  An entity is a *permitted result of a constant expression* if it is an
314
+ object with static storage duration that either is not a temporary
315
  object or is a temporary object whose value satisfies the above
316
+ constraints, or if it is a non-immediate function.
317
 
318
+ [*Example 5*:
319
 
320
+ ``` cpp
321
+ consteval int f() { return 42; }
322
+ consteval auto g() { return f; }
323
+ consteval int h(int (*p)() = g()) { return p(); }
324
+ constexpr int r = h(); // OK
325
+ constexpr auto e = g(); // error: a pointer to an immediate function is
326
+ // not a permitted result of a constant expression
327
+ ```
328
 
329
+ *end example*]
330
+
331
+ [*Note 8*:
332
+
333
+ Since this document imposes no restrictions on the accuracy of
334
+ floating-point operations, it is unspecified whether the evaluation of a
335
+ floating-point expression during translation yields the same result as
336
+ the evaluation of the same expression (or the same operations on the
337
+ same values) during program execution.[^32]
338
+
339
+ [*Example 6*:
340
 
341
  ``` cpp
342
  bool f() {
343
  char array[1 + int(1 + 0.2 - 0.1 - 0.1)]; // Must be evaluated during translation
344
  int size = 1 + int(1 + 0.2 - 0.1 - 0.1); // May be evaluated at runtime
 
350
 
351
  — *end example*]
352
 
353
  — *end note*]
354
 
355
+ An expression or conversion is in an *immediate function context* if it
356
+ is potentially evaluated and its innermost non-block scope is a function
357
+ parameter scope of an immediate function. An expression or conversion is
358
+ an *immediate invocation* if it is a potentially-evaluated explicit or
359
+ implicit invocation of an immediate function and is not in an immediate
360
+ function context. An immediate invocation shall be a constant
361
+ expression.
362
 
363
+ An expression or conversion is *manifestly constant-evaluated* if it is:
364
 
365
+ - a *constant-expression*, or
366
+ - the condition of a constexpr if statement [[stmt.if]], or
367
+ - an immediate invocation, or
368
+ - the result of substitution into an atomic constraint expression to
369
+ determine whether it is satisfied [[temp.constr.atomic]], or
370
+ - the initializer of a variable that is usable in constant expressions
371
+ or has constant initialization.[^33]
372
+ \[*Example 7*:
373
  ``` cpp
374
+ template<bool> struct X {};
375
+ X<std::is_constant_evaluated()> x; // type X<true>
376
+ int y;
377
+ const int a = std::is_constant_evaluated() ? y : 1; // dynamic initialization to 1
378
+ double z[a]; // error: a is not usable
379
+ // in constant expressions
380
+ const int b = std::is_constant_evaluated() ? 2 : y; // static initialization to 2
381
+ int c = y + (std::is_constant_evaluated() ? 2 : y); // dynamic initialization to y+y
382
+
383
+ constexpr int f() {
384
+ const int n = std::is_constant_evaluated() ? 13 : 17; // n is 13
385
+ int m = std::is_constant_evaluated() ? 13 : 17; // m might be 13 or 17 (see below)
386
+ char arr[n] = {}; // char[13]
387
+ return m + sizeof(arr);
388
+ }
389
+ int p = f(); // m is 13; initialized to 26
390
+ int q = p + f(); // m is 17 for this call; initialized to 56
391
  ```
392
 
393
  — *end example*]
394
 
395
+ [*Note 9*: A manifestly constant-evaluated expression is evaluated even
396
+ in an unevaluated operand. — *end note*]
397
+
398
+ An expression or conversion is *potentially constant evaluated* if it
399
+ is:
400
+
401
+ - a manifestly constant-evaluated expression,
402
+ - a potentially-evaluated expression [[basic.def.odr]],
403
+ - an immediate subexpression of a *braced-init-list*, [^34]
404
+ - an expression of the form `&` *cast-expression* that occurs within a
405
+ templated entity, [^35] or
406
+ - a subexpression of one of the above that is not a subexpression of a
407
+ nested unevaluated operand.
408
+
409
+ A function or variable is *needed for constant evaluation* if it is:
410
+
411
+ - a constexpr function that is named by an expression [[basic.def.odr]]
412
+ that is potentially constant evaluated, or
413
+ - a variable whose name appears as a potentially constant evaluated
414
+ expression that is either a constexpr variable or is of non-volatile
415
+ const-qualified integral type or of reference type.
416
+
417
  <!-- Link reference definitions -->
418
+ [allocator.members]: utilities.md#allocator.members
419
+ [bad.alloc]: support.md#bad.alloc
420
+ [bad.cast]: support.md#bad.cast
421
+ [bad.typeid]: support.md#bad.typeid
422
  [basic.align]: basic.md#basic.align
423
  [basic.compound]: basic.md#basic.compound
424
  [basic.def.odr]: basic.md#basic.def.odr
425
  [basic.fundamental]: basic.md#basic.fundamental
426
+ [basic.indet]: basic.md#basic.indet
427
  [basic.life]: basic.md#basic.life
428
  [basic.lookup]: basic.md#basic.lookup
429
  [basic.lookup.argdep]: basic.md#basic.lookup.argdep
430
  [basic.lookup.classref]: basic.md#basic.lookup.classref
431
  [basic.lookup.unqual]: basic.md#basic.lookup.unqual
432
+ [basic.lval]: #basic.lval
433
  [basic.namespace]: dcl.md#basic.namespace
434
  [basic.scope.block]: basic.md#basic.scope.block
435
  [basic.scope.class]: basic.md#basic.scope.class
436
  [basic.start.main]: basic.md#basic.start.main
437
  [basic.stc.dynamic]: basic.md#basic.stc.dynamic
 
442
  [basic.types]: basic.md#basic.types
443
  [class]: class.md#class
444
  [class.abstract]: class.md#class.abstract
445
  [class.access]: class.md#class.access
446
  [class.access.base]: class.md#class.access.base
447
+ [class.base.init]: class.md#class.base.init
448
  [class.bit]: class.md#class.bit
449
+ [class.cdtor]: class.md#class.cdtor
450
+ [class.conv]: class.md#class.conv
451
+ [class.conv.fct]: class.md#class.conv.fct
452
+ [class.copy.assign]: class.md#class.copy.assign
453
+ [class.copy.ctor]: class.md#class.copy.ctor
454
+ [class.copy.elision]: class.md#class.copy.elision
455
+ [class.ctor]: class.md#class.ctor
456
  [class.derived]: class.md#class.derived
457
+ [class.dtor]: class.md#class.dtor
458
+ [class.free]: class.md#class.free
459
  [class.friend]: class.md#class.friend
 
460
  [class.mem]: class.md#class.mem
461
  [class.member.lookup]: class.md#class.member.lookup
462
  [class.mfct]: class.md#class.mfct
463
  [class.mfct.non-static]: class.md#class.mfct.non-static
464
+ [class.mi]: class.md#class.mi
465
+ [class.prop]: class.md#class.prop
466
  [class.qual]: basic.md#class.qual
467
+ [class.spaceship]: class.md#class.spaceship
468
  [class.static]: class.md#class.static
469
+ [class.temporary]: basic.md#class.temporary
470
  [class.this]: class.md#class.this
471
  [class.union]: class.md#class.union
472
  [class.virtual]: class.md#class.virtual
473
+ [cmp.categories]: support.md#cmp.categories
474
+ [conv]: #conv
475
+ [conv.array]: #conv.array
476
+ [conv.bool]: #conv.bool
477
+ [conv.double]: #conv.double
478
+ [conv.fctptr]: #conv.fctptr
479
+ [conv.fpint]: #conv.fpint
480
+ [conv.fpprom]: #conv.fpprom
481
+ [conv.func]: #conv.func
482
+ [conv.integral]: #conv.integral
483
+ [conv.lval]: #conv.lval
484
+ [conv.mem]: #conv.mem
485
+ [conv.prom]: #conv.prom
486
+ [conv.ptr]: #conv.ptr
487
+ [conv.qual]: #conv.qual
488
+ [conv.rank]: basic.md#conv.rank
489
+ [conv.rval]: #conv.rval
490
  [cpp]: cpp.md#cpp
491
+ [cstdarg.syn]: support.md#cstdarg.syn
492
+ [cstddef.syn]: support.md#cstddef.syn
493
  [dcl.align]: dcl.md#dcl.align
494
  [dcl.array]: dcl.md#dcl.array
495
+ [dcl.asm]: dcl.md#dcl.asm
496
  [dcl.constexpr]: dcl.md#dcl.constexpr
497
  [dcl.dcl]: dcl.md#dcl.dcl
498
+ [dcl.decl]: dcl.md#dcl.decl
499
  [dcl.enum]: dcl.md#dcl.enum
500
  [dcl.fct]: dcl.md#dcl.fct
501
  [dcl.fct.def]: dcl.md#dcl.fct.def
502
+ [dcl.fct.def.coroutine]: dcl.md#dcl.fct.def.coroutine
503
  [dcl.fct.def.general]: dcl.md#dcl.fct.def.general
504
  [dcl.fct.default]: dcl.md#dcl.fct.default
505
  [dcl.init]: dcl.md#dcl.init
506
  [dcl.init.aggr]: dcl.md#dcl.init.aggr
507
  [dcl.init.list]: dcl.md#dcl.init.list
508
  [dcl.init.ref]: dcl.md#dcl.init.ref
509
+ [dcl.init.string]: dcl.md#dcl.init.string
510
  [dcl.link]: dcl.md#dcl.link
511
+ [dcl.mptr]: dcl.md#dcl.mptr
512
  [dcl.name]: dcl.md#dcl.name
513
+ [dcl.ptr]: dcl.md#dcl.ptr
514
  [dcl.ref]: dcl.md#dcl.ref
515
  [dcl.spec.auto]: dcl.md#dcl.spec.auto
516
  [dcl.stc]: dcl.md#dcl.stc
517
  [dcl.struct.bind]: dcl.md#dcl.struct.bind
518
  [dcl.type]: dcl.md#dcl.type
519
  [dcl.type.cv]: dcl.md#dcl.type.cv
520
  [dcl.type.simple]: dcl.md#dcl.type.simple
521
+ [defns.access]: intro.md#defns.access
522
+ [depr.arith.conv.enum]: future.md#depr.arith.conv.enum
523
+ [depr.array.comp]: future.md#depr.array.comp
524
+ [depr.capture.this]: future.md#depr.capture.this
525
+ [depr.comma.subscript]: future.md#depr.comma.subscript
526
+ [depr.volatile.type]: future.md#depr.volatile.type
527
  [except]: except.md#except
528
  [except.handle]: except.md#except.handle
529
+ [except.pre]: except.md#except.pre
530
  [except.spec]: except.md#except.spec
531
  [except.terminate]: except.md#except.terminate
532
  [except.throw]: except.md#except.throw
533
  [expr]: #expr
534
  [expr.add]: #expr.add
535
  [expr.alignof]: #expr.alignof
536
+ [expr.arith.conv]: #expr.arith.conv
537
  [expr.ass]: #expr.ass
538
+ [expr.await]: #expr.await
539
  [expr.bit.and]: #expr.bit.and
540
  [expr.call]: #expr.call
541
  [expr.cast]: #expr.cast
542
  [expr.comma]: #expr.comma
543
+ [expr.compound]: #expr.compound
544
  [expr.cond]: #expr.cond
545
  [expr.const]: #expr.const
546
  [expr.const.cast]: #expr.const.cast
547
+ [expr.context]: #expr.context
548
  [expr.delete]: #expr.delete
549
  [expr.dynamic.cast]: #expr.dynamic.cast
550
  [expr.eq]: #expr.eq
551
  [expr.log.and]: #expr.log.and
552
  [expr.log.or]: #expr.log.or
 
554
  [expr.mul]: #expr.mul
555
  [expr.new]: #expr.new
556
  [expr.or]: #expr.or
557
  [expr.post]: #expr.post
558
  [expr.post.incr]: #expr.post.incr
559
+ [expr.pre]: #expr.pre
560
  [expr.pre.incr]: #expr.pre.incr
561
  [expr.prim]: #expr.prim
562
  [expr.prim.fold]: #expr.prim.fold
563
  [expr.prim.id]: #expr.prim.id
564
+ [expr.prim.id.dtor]: #expr.prim.id.dtor
565
  [expr.prim.id.qual]: #expr.prim.id.qual
566
  [expr.prim.id.unqual]: #expr.prim.id.unqual
567
  [expr.prim.lambda]: #expr.prim.lambda
568
  [expr.prim.lambda.capture]: #expr.prim.lambda.capture
569
  [expr.prim.lambda.closure]: #expr.prim.lambda.closure
570
  [expr.prim.literal]: #expr.prim.literal
571
  [expr.prim.paren]: #expr.prim.paren
572
+ [expr.prim.req]: #expr.prim.req
573
+ [expr.prim.req.compound]: #expr.prim.req.compound
574
+ [expr.prim.req.nested]: #expr.prim.req.nested
575
+ [expr.prim.req.simple]: #expr.prim.req.simple
576
+ [expr.prim.req.type]: #expr.prim.req.type
577
  [expr.prim.this]: #expr.prim.this
578
+ [expr.prop]: #expr.prop
579
  [expr.ref]: #expr.ref
580
  [expr.reinterpret.cast]: #expr.reinterpret.cast
581
  [expr.rel]: #expr.rel
582
  [expr.shift]: #expr.shift
583
  [expr.sizeof]: #expr.sizeof
584
+ [expr.spaceship]: #expr.spaceship
585
  [expr.static.cast]: #expr.static.cast
586
  [expr.sub]: #expr.sub
587
  [expr.throw]: #expr.throw
588
+ [expr.type]: #expr.type
589
  [expr.type.conv]: #expr.type.conv
590
  [expr.typeid]: #expr.typeid
591
  [expr.unary]: #expr.unary
592
  [expr.unary.noexcept]: #expr.unary.noexcept
593
  [expr.unary.op]: #expr.unary.op
594
  [expr.xor]: #expr.xor
595
+ [expr.yield]: #expr.yield
596
  [function.objects]: utilities.md#function.objects
597
  [implimits]: limits.md#implimits
598
  [intro]: intro.md#intro
599
+ [intro.execution]: basic.md#intro.execution
600
+ [intro.memory]: basic.md#intro.memory
601
+ [intro.object]: basic.md#intro.object
602
+ [lex.ext]: lex.md#lex.ext
603
+ [lex.icon]: lex.md#lex.icon
604
  [lex.literal]: lex.md#lex.literal
605
  [lex.string]: lex.md#lex.string
606
  [library]: library.md#library
607
+ [meta.const.eval]: utilities.md#meta.const.eval
608
  [namespace.qual]: basic.md#namespace.qual
609
+ [new.badlength]: support.md#new.badlength
610
+ [new.delete.array]: support.md#new.delete.array
611
+ [new.delete.placement]: support.md#new.delete.placement
612
+ [new.delete.single]: support.md#new.delete.single
613
  [over]: over.md#over
614
  [over.ass]: over.md#over.ass
615
  [over.best.ics]: over.md#over.best.ics
616
  [over.built]: over.md#over.built
617
  [over.call]: over.md#over.call
 
622
  [over.match.oper]: over.md#over.match.oper
623
  [over.match.viable]: over.md#over.match.viable
624
  [over.oper]: over.md#over.oper
625
  [over.over]: over.md#over.over
626
  [replacement.functions]: library.md#replacement.functions
627
+ [special]: class.md#special
628
+ [stmt.if]: stmt.md#stmt.if
629
+ [stmt.iter]: stmt.md#stmt.iter
630
+ [stmt.jump]: stmt.md#stmt.jump
631
  [stmt.return]: stmt.md#stmt.return
632
  [stmt.switch]: stmt.md#stmt.switch
633
+ [support.runtime]: support.md#support.runtime
634
+ [support.types.layout]: support.md#support.types.layout
 
635
  [temp.arg]: temp.md#temp.arg
636
+ [temp.concept]: temp.md#temp.concept
637
+ [temp.constr.atomic]: temp.md#temp.constr.atomic
638
+ [temp.constr.constr]: temp.md#temp.constr.constr
639
+ [temp.constr.decl]: temp.md#temp.constr.decl
640
+ [temp.dep.constexpr]: temp.md#temp.dep.constexpr
641
  [temp.expl.spec]: temp.md#temp.expl.spec
642
  [temp.explicit]: temp.md#temp.explicit
 
643
  [temp.names]: temp.md#temp.names
644
+ [temp.param]: temp.md#temp.param
645
+ [temp.pre]: temp.md#temp.pre
646
  [temp.res]: temp.md#temp.res
647
  [temp.variadic]: temp.md#temp.variadic
648
  [thread]: thread.md#thread
649
+ [type.info]: support.md#type.info
650
 
651
  [^1]: The precedence of operators is not directly specified, but it can
652
  be derived from the syntax.
653
 
654
+ [^2]: Overloaded operators are never assumed to be associative or
655
+ commutative.
 
656
 
657
  [^3]: The cast and assignment operators must still perform their
658
+ specific conversions as described in  [[expr.type.conv]],
659
+ [[expr.cast]], [[expr.static.cast]] and  [[expr.ass]].
660
 
661
+ [^4]: The intent of this list is to specify those circumstances in which
662
+ an object may or may not be aliased.
663
+
664
+ [^5]: For historical reasons, this conversion is called the
665
+ “lvalue-to-rvalue” conversion, even though that name does not
666
+ accurately reflect the taxonomy of expressions described in 
667
+ [[basic.lval]].
668
+
669
+ [^6]: In C++ class and array prvalues can have cv-qualified types. This
670
+ differs from ISO C, in which non-lvalues never have cv-qualified
671
+ types.
672
+
673
+ [^7]: This conversion never applies to non-static member functions
674
+ because an lvalue that refers to a non-static member function cannot
675
+ be obtained.
676
+
677
+ [^8]: The rule for conversion of pointers to members (from pointer to
678
+ member of base to pointer to member of derived) appears inverted
679
+ compared to the rule for pointers to objects (from pointer to
680
+ derived to pointer to base) ([[conv.ptr]], [[class.derived]]). This
681
+ inversion is necessary to ensure type safety. Note that a pointer to
682
+ member is not an object pointer or a function pointer and the rules
683
+ for conversions of such pointers do not apply to pointers to
684
+ members. In particular, a pointer to member cannot be converted to a
685
+ `void*`.
686
+
687
+ [^9]: As a consequence, operands of type `bool`, `char8_t`, `char16_t`,
688
+ `char32_t`, `wchar_t`, or an enumerated type are converted to some
689
+ integral type.
690
+
691
+ [^10]: This also applies when the object expression is an implicit
692
  `(*this)` ([[class.mfct.non-static]]).
693
 
694
+ [^11]: This is true even if the subscript operator is used in the
695
  following common idiom: `&x[0]`.
696
 
697
+ [^12]: If the class member access expression is evaluated, the
698
  subexpression evaluation happens even if the result is unnecessary
699
  to determine the value of the entire postfix expression, for example
700
  if the *id-expression* denotes a static member.
701
 
702
+ [^13]: Note that `(*(E1))` is an lvalue.
703
 
704
+ [^14]: The most derived object [[intro.object]] pointed or referred to
705
  by `v` can contain other `B` objects as base classes, but these are
706
  ignored.
707
 
708
+ [^15]: The recommended name for such a class is `extended_type_info`.
709
 
710
+ [^16]: If `p` is an expression of pointer type, then `*p`, `(*p)`,
711
  `*(p)`, `((*p))`, `*((p))`, and so on all meet this requirement.
712
 
713
+ [^17]: The types may have different cv-qualifiers, subject to the
 
 
 
714
  overall restriction that a `reinterpret_cast` cannot cast away
715
  constness.
716
 
717
+ [^18]: `T1` and `T2` may have different cv-qualifiers, subject to the
718
  overall restriction that a `reinterpret_cast` cannot cast away
719
  constness.
720
 
721
+ [^19]: This is sometimes referred to as a *type pun* when the result
722
+ refers to the same object as the source glvalue.
723
 
724
+ [^20]: `const_cast`
725
 
726
  is not limited to conversions that cast away a const-qualifier.
727
 
728
+ [^21]: `sizeof(bool)` is not required to be `1`.
729
 
730
+ [^22]: The actual size of a potentially-overlapping subobject may be
731
+ less than the result of applying `sizeof` to the subobject, due to
732
+ virtual base classes and less strict padding requirements on
733
+ potentially-overlapping subobjects.
734
 
735
+ [^23]: If the conversion function returns a signed integer type, the
736
  second standard conversion converts to the unsigned type
737
  `std::size_t` and thus thwarts any attempt to detect a negative
738
  value afterwards.
739
 
740
+ [^24]: This may include evaluating a *new-initializer* and/or calling a
741
  constructor.
742
 
743
+ [^25]: A *lambda-expression* with a *lambda-introducer* that consists of
744
+ empty square brackets can follow the `delete` keyword if the
745
+ *lambda-expression* is enclosed in parentheses.
746
 
747
+ [^26]: This implies that an object cannot be deleted using a pointer of
748
  type `void*` because `void` is not an object type.
749
 
750
+ [^27]: For nonzero-length arrays, this is the same as a pointer to the
751
  first element of the array created by that *new-expression*.
752
  Zero-length arrays do not have a first element.
753
 
754
+ [^28]: This is often called truncation towards zero.
 
 
 
755
 
756
+ [^29]: As specified in [[basic.compound]], an object that is not an
757
+ array element is considered to belong to a single-element array for
758
+ this purpose and a pointer past the last element of an array of n
759
+ elements is considered to be equivalent to a pointer to a
760
+ hypothetical array element n for this purpose.
761
 
762
+ [^30]: As specified in [[basic.compound]], an object that is not an
763
+ array element is considered to belong to a single-element array for
764
+ this purpose and a pointer past the last element of an array of n
765
+ elements is considered to be equivalent to a pointer to a
766
+ hypothetical array element n for this purpose.
767
 
768
+ [^31]: As specified in [[basic.compound]], an object that is not an
769
+ array element is considered to belong to a single-element array for
770
+ this purpose.
 
 
771
 
772
+ [^32]: Nonetheless, implementations should provide consistent results,
773
+ irrespective of whether the evaluation was performed during
 
 
 
774
  translation and/or during program execution.
775
+
776
+ [^33]: Testing this condition may involve a trial evaluation of its
777
+ initializer as described above.
778
+
779
+ [^34]: Constant evaluation may be necessary to determine whether a
780
+ narrowing conversion is performed [[dcl.init.list]].
781
+
782
+ [^35]: Constant evaluation may be necessary to determine whether such an
783
+ expression is value-dependent [[temp.dep.constexpr]].