From Jason Turner

[expr.unary]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpejmkgq0n/{from.md → to.md} +184 -89
tmp/tmpejmkgq0n/{from.md → to.md} RENAMED
@@ -26,15 +26,15 @@ unary-operator: one of
26
 
27
  The unary `*` operator performs *indirection*: the expression to which
28
  it is applied shall be a pointer to an object type, or a pointer to a
29
  function type and the result is an lvalue referring to the object or
30
  function to which the expression points. If the type of the expression
31
- is “pointer to `T`,” the type of the result is “`T`.” a pointer to an
32
- incomplete type (other than *cv* `void`) can be dereferenced. The lvalue
33
- thus obtained can be used in limited ways (to initialize a reference,
34
- for example); this lvalue must not be converted to a prvalue, see 
35
- [[conv.lval]].
36
 
37
  The result of each of the following unary operators is a prvalue.
38
 
39
  The result of the unary `&` operator is a pointer to its operand. The
40
  operand shall be an lvalue or a *qualified-id*. If the operand is a
@@ -66,14 +66,14 @@ from a *qualified-id* for a non-static member function to the type
66
  “pointer to member function” as there is from an lvalue of function type
67
  to the type “pointer to function” ([[conv.func]]). Nor is
68
  `&unqualified-id` a pointer to member, even within the scope of the
69
  *unqualified-id*’s class.
70
 
71
- The address of an object of incomplete type can be taken, but if the
72
- complete type of that object is a class type that declares `operator&()`
73
- as a member function, then the behavior is undefined (and no diagnostic
74
- is required). The operand of `&` shall not be a bit-field.
75
 
76
  The address of an overloaded function (Clause  [[over]]) can be taken
77
  only in a context that uniquely determines which version of the
78
  overloaded function is referred to (see  [[over.over]]). since the
79
  context might determine whether the operand is a static or non-static
@@ -128,27 +128,27 @@ The `sizeof` operator yields the number of bytes in the object
128
  representation of its operand. The operand is either an expression,
129
  which is an unevaluated operand (Clause  [[expr]]), or a parenthesized
130
  *type-id*. The `sizeof` operator shall not be applied to an expression
131
  that has function or incomplete type, to an enumeration type whose
132
  underlying type is not fixed before all its enumerators have been
133
- declared, to the parenthesized name of such types, or to an lvalue that
134
  designates a bit-field. `sizeof(char)`, `sizeof(signed char)` and
135
  `sizeof(unsigned char)` are `1`. The result of `sizeof` applied to any
136
  other fundamental type ([[basic.fundamental]]) is
137
  *implementation-defined*. in particular, `sizeof(bool)`,
138
  `sizeof(char16_t)`, `sizeof(char32_t)`, and `sizeof(wchar_t)` are
139
- implementation-defined.[^17] See  [[intro.memory]] for the definition of
140
  *byte* and  [[basic.types]] for the definition of *object
141
  representation*.
142
 
143
  When applied to a reference or a reference type, the result is the size
144
  of the referenced type. When applied to a class, the result is the
145
  number of bytes in an object of that class including any padding
146
  required for placing objects of that type in an array. The size of a
147
  most derived class shall be greater than zero ([[intro.object]]). The
148
  result of applying `sizeof` to a base class subobject is the size of the
149
- base class type.[^18] When applied to an array, the result is the total
150
  number of bytes in the array. This implies that the size of an array of
151
  *n* elements is *n* times the size of an element.
152
 
153
  The `sizeof` operator can be applied to a pointer to a function, but
154
  shall not be applied directly to a function.
@@ -287,35 +287,43 @@ denotes an array type), the *new-expression* yields a pointer to the
287
  initial element (if any) of the array. both `new int` and `new int[10]`
288
  have type `int*` and the type of `new int[i][10]` is `int (*)[10]` The
289
  *attribute-specifier-seq* in a *noptr-new-declarator* appertains to the
290
  associated array type.
291
 
292
- Every *constant-expression* in a *noptr-new-declarator* shall be an
293
- integral constant expression ([[expr.const]]) and evaluate to a
294
- strictly positive value. The *expression* in a *noptr-new-declarator*
295
- shall be of integral type, unscoped enumeration type, or a class type
296
- for which a single non-explicit conversion function to integral or
297
- unscoped enumeration type exists ([[class.conv]]). If the expression is
298
- of class type, the expression is converted by calling that conversion
299
- function, and the result of the conversion is used in place of the
300
- original expression. given the definition `int n = 42`,
301
- `new float[n][5]` is well-formed (because `n` is the *expression* of a
302
- *noptr-new-declarator*), but `new float[5][n]` is ill-formed (because
303
- `n` is not a constant expression).
304
 
305
- When the value of the *expression* in a *noptr-new-declarator* is zero,
306
- the allocation function is called to allocate an array with no elements.
307
- If the value of that *expression* is less than zero or such that the
308
- size of the allocated object would exceed the implementation-defined
309
- limit, or if the *new-initializer* is a *braced-init-list* for which the
310
- number of *initializer-clause*s exceeds the number of elements to
311
- initialize, no storage is obtained and the *new-expression* terminates
312
- by throwing an exception of a type that would match a handler (
313
- [[except.handle]]) of type `std::bad_array_new_length` (
314
- [[new.badlength]]).
315
 
316
- A *new-expression* obtains storage for the object by calling an
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
317
  *allocation function* ([[basic.stc.dynamic.allocation]]). If the
318
  *new-expression* terminates by throwing an exception, it may release
319
  storage by calling a deallocation function (
320
  [[basic.stc.dynamic.deallocation]]). If the allocated type is a
321
  non-array type, the allocation function’s name is `operator new` and the
@@ -333,24 +341,76 @@ allocation function’s name is looked up in the global scope. Otherwise,
333
  if the allocated type is a class type `T` or array thereof, the
334
  allocation function’s name is looked up in the scope of `T`. If this
335
  lookup fails to find the name, or if the allocated type is not a class
336
  type, the allocation function’s name is looked up in the global scope.
337
 
338
- A *new-expression* passes the amount of space requested to the
339
- allocation function as the first argument of type `std::size_t`. That
340
- argument shall be no less than the size of the object being created; it
341
- may be greater than the size of the object being created only if the
342
- object is an array. For arrays of `char` and `unsigned char`, the
343
- difference between the result of the *new-expression* and the address
344
- returned by the allocation function shall be an integral multiple of the
345
- strictest fundamental alignment requirement ([[basic.align]]) of any
346
- object type whose size is no greater than the size of the array being
347
- created. Because allocation functions are assumed to return pointers to
348
- storage that is appropriately aligned for objects of any type with
349
- fundamental alignment, this constraint on array allocation overhead
350
- permits the common idiom of allocating character arrays into which
351
- objects of other types will later be placed.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
352
 
353
  The *new-placement* syntax is used to supply additional arguments to an
354
  allocation function. If used, overload resolution is performed on a
355
  function call created by assembling an argument list consisting of the
356
  amount of space requested (the first argument) and the expressions in
@@ -395,12 +455,12 @@ necessarily be the same as that of the block if the object is an array.
395
 
396
  A *new-expression* that creates an object of type `T` initializes that
397
  object as follows:
398
 
399
  - If the *new-initializer* is omitted, the object is
400
- default-initialized ([[dcl.init]]); if no initialization is
401
- performed, the object has indeterminate value.
402
  - Otherwise, the *new-initializer* is interpreted according to the
403
  initialization rules of  [[dcl.init]] for direct-initialization.
404
 
405
  The invocation of the allocation function is indeterminately sequenced
406
  with respect to the evaluations of expressions in the *new-initializer*.
@@ -410,23 +470,24 @@ expressions in the *new-initializer* are evaluated if the allocation
410
  function returns the null pointer or exits using an exception.
411
 
412
  If the *new-expression* creates an object or an array of objects of
413
  class type, access and ambiguity control are done for the allocation
414
  function, the deallocation function ([[class.free]]), and the
415
- constructor ([[class.ctor]]). If the new expression creates an array of
416
- objects of class type, access and ambiguity control are done for the
417
- destructor ([[class.dtor]]).
418
 
419
  If any part of the object initialization described above[^19] terminates
420
- by throwing an exception and a suitable deallocation function can be
421
- found, the deallocation function is called to free the memory in which
422
- the object was being constructed, after which the exception continues to
423
- propagate in the context of the *new-expression*. If no unambiguous
424
- matching deallocation function can be found, propagating the exception
425
- does not cause the object’s memory to be freed. This is appropriate when
426
- the called allocation function does not allocate memory; otherwise, it
427
- is likely to result in a memory leak.
 
428
 
429
  If the *new-expression* begins with a unary `::` operator, the
430
  deallocation function’s name is looked up in the global scope.
431
  Otherwise, if the allocated type is a class type `T` or an array
432
  thereof, the deallocation function’s name is looked up in the scope of
@@ -435,19 +496,19 @@ not a class type or array thereof, the deallocation function’s name is
435
  looked up in the global scope.
436
 
437
  A declaration of a placement deallocation function matches the
438
  declaration of a placement allocation function if it has the same number
439
  of parameters and, after parameter transformations ([[dcl.fct]]), all
440
- parameter types except the first are identical. Any non-placement
441
- deallocation function matches a non-placement allocation function. If
442
- the lookup finds a single matching deallocation function, that function
443
- will be called; otherwise, no deallocation function will be called. If
444
- the lookup finds the two-parameter form of a usual deallocation
445
- function ([[basic.stc.dynamic.deallocation]]) and that function,
446
- considered as a placement deallocation function, would have been
447
- selected as a match for the allocation function, the program is
448
- ill-formed.
449
 
450
  ``` cpp
451
  struct S {
452
  // Placement allocation function:
453
  static void* operator new(std::size_t, std::size_t);
@@ -484,13 +545,14 @@ delete-expression:
484
  ```
485
 
486
  The first alternative is for non-array objects, and the second is for
487
  arrays. Whenever the `delete` keyword is immediately followed by empty
488
  square brackets, it shall be interpreted as the second alternative.[^20]
489
- The operand shall have a pointer to object type, or a class type having
490
- a single non-explicit conversion function ([[class.conv.fct]]) to a
491
- pointer to object type. The result has type `void`.[^21]
 
492
 
493
  If the operand has a class type, the operand is converted to a pointer
494
  type by calling the above-mentioned conversion function, and the
495
  converted operand is used in place of the original operand for the
496
  remainder of this section. In the first alternative (*delete object*),
@@ -529,41 +591,74 @@ any) for the object or the elements of the array being deleted. In the
529
  case of an array, the elements will be destroyed in order of decreasing
530
  address (that is, in reverse order of the completion of their
531
  constructor; see  [[class.base.init]]).
532
 
533
  If the value of the operand of the *delete-expression* is not a null
534
- pointer value, the *delete-expression* will call a *deallocation
535
- function* ([[basic.stc.dynamic.deallocation]]). Otherwise, it is
536
- unspecified whether the deallocation function will be called. The
537
- deallocation function is called regardless of whether the destructor for
538
- the object or some element of the array throws an exception.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
539
 
540
  An implementation provides default definitions of the global
541
  deallocation functions `operator delete()` for non-arrays (
542
  [[new.delete.single]]) and `operator delete[]()` for arrays (
543
  [[new.delete.array]]). A C++ program can provide alternative definitions
544
  of these functions ([[replacement.functions]]), and/or class-specific
545
  versions ([[class.free]]).
546
 
547
  When the keyword `delete` in a *delete-expression* is preceded by the
548
- unary `::` operator, the global deallocation function is used to
549
- deallocate the storage.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
550
 
551
  Access and ambiguity control are done for both the deallocation function
552
  and the destructor ([[class.dtor]],  [[class.free]]).
553
 
554
  ### Alignof <a id="expr.alignof">[[expr.alignof]]</a>
555
 
556
  An `alignof` expression yields the alignment requirement of its operand
557
  type. The operand shall be a *type-id* representing a complete object
558
- type or an array thereof or a reference to a complete object type.
559
 
560
  The result is an integral constant of type `std::size_t`.
561
 
562
- When `alignof` is applied to a reference type, the result shall be the
563
  alignment of the referenced type. When `alignof` is applied to an array
564
- type, the result shall be the alignment of the element type.
565
 
566
  ### `noexcept` operator <a id="expr.unary.noexcept">[[expr.unary.noexcept]]</a>
567
 
568
  The `noexcept` operator determines whether the evaluation of its
569
  operand, which is an unevaluated operand (Clause  [[expr]]), can throw
@@ -573,24 +668,24 @@ an exception ([[except.throw]]).
573
  noexcept-expression:
574
  'noexcept' '(' expression ')'
575
  ```
576
 
577
  The result of the `noexcept` operator is a constant of type `bool` and
578
- is an rvalue.
579
 
580
  The result of the `noexcept` operator is `false` if in a
581
  potentially-evaluated context the *expression* would contain
582
 
583
- - a potentially evaluated call[^23] to a function, member function,
584
  function pointer, or member function pointer that does not have a
585
  non-throwing *exception-specification* ([[except.spec]]), unless the
586
  call is a constant expression ([[expr.const]]),
587
- - a potentially evaluated *throw-expression* ([[except.throw]]),
588
- - a potentially evaluated `dynamic_cast` expression
589
  `dynamic_cast<T>(v)`, where `T` is a reference type, that requires a
590
  run-time check ([[expr.dynamic.cast]]), or
591
- - a potentially evaluated `typeid` expression ([[expr.typeid]]) applied
592
  to a glvalue expression whose type is a polymorphic class type (
593
  [[class.virtual]]).
594
 
595
  Otherwise, the result is `true`.
596
 
 
26
 
27
  The unary `*` operator performs *indirection*: the expression to which
28
  it is applied shall be a pointer to an object type, or a pointer to a
29
  function type and the result is an lvalue referring to the object or
30
  function to which the expression points. If the type of the expression
31
+ is “pointer to `T`,” the type of the result is “`T`.” indirection
32
+ through a pointer to an incomplete type (other than *cv* `void`) is
33
+ valid. The lvalue thus obtained can be used in limited ways (to
34
+ initialize a reference, for example); this lvalue must not be converted
35
+ to a prvalue, see  [[conv.lval]].
36
 
37
  The result of each of the following unary operators is a prvalue.
38
 
39
  The result of the unary `&` operator is a pointer to its operand. The
40
  operand shall be an lvalue or a *qualified-id*. If the operand is a
 
66
  “pointer to member function” as there is from an lvalue of function type
67
  to the type “pointer to function” ([[conv.func]]). Nor is
68
  `&unqualified-id` a pointer to member, even within the scope of the
69
  *unqualified-id*’s class.
70
 
71
+ If `&` is applied to an lvalue of incomplete class type and the complete
72
+ type declares `operator&()`, it is unspecified whether the operator has
73
+ the built-in meaning or the operator function is called. The operand of
74
+ `&` shall not be a bit-field.
75
 
76
  The address of an overloaded function (Clause  [[over]]) can be taken
77
  only in a context that uniquely determines which version of the
78
  overloaded function is referred to (see  [[over.over]]). since the
79
  context might determine whether the operand is a static or non-static
 
128
  representation of its operand. The operand is either an expression,
129
  which is an unevaluated operand (Clause  [[expr]]), or a parenthesized
130
  *type-id*. The `sizeof` operator shall not be applied to an expression
131
  that has function or incomplete type, to an enumeration type whose
132
  underlying type is not fixed before all its enumerators have been
133
+ declared, to the parenthesized name of such types, or to a glvalue that
134
  designates a bit-field. `sizeof(char)`, `sizeof(signed char)` and
135
  `sizeof(unsigned char)` are `1`. The result of `sizeof` applied to any
136
  other fundamental type ([[basic.fundamental]]) is
137
  *implementation-defined*. in particular, `sizeof(bool)`,
138
  `sizeof(char16_t)`, `sizeof(char32_t)`, and `sizeof(wchar_t)` are
139
+ implementation-defined.[^16] See  [[intro.memory]] for the definition of
140
  *byte* and  [[basic.types]] for the definition of *object
141
  representation*.
142
 
143
  When applied to a reference or a reference type, the result is the size
144
  of the referenced type. When applied to a class, the result is the
145
  number of bytes in an object of that class including any padding
146
  required for placing objects of that type in an array. The size of a
147
  most derived class shall be greater than zero ([[intro.object]]). The
148
  result of applying `sizeof` to a base class subobject is the size of the
149
+ base class type.[^17] When applied to an array, the result is the total
150
  number of bytes in the array. This implies that the size of an array of
151
  *n* elements is *n* times the size of an element.
152
 
153
  The `sizeof` operator can be applied to a pointer to a function, but
154
  shall not be applied directly to a function.
 
287
  initial element (if any) of the array. both `new int` and `new int[10]`
288
  have type `int*` and the type of `new int[i][10]` is `int (*)[10]` The
289
  *attribute-specifier-seq* in a *noptr-new-declarator* appertains to the
290
  associated array type.
291
 
292
+ Every *constant-expression* in a *noptr-new-declarator* shall be a
293
+ converted constant expression ([[expr.const]]) of type `std::size_t`
294
+ and shall evaluate to a strictly positive value. The *expression* in a
295
+ *noptr-new-declarator*is implicitly converted to `std::size_t`. given
296
+ the definition `int n = 42`, `new float[n][5]` is well-formed (because
297
+ `n` is the *expression* of a *noptr-new-declarator*), but
298
+ `new float[5][n]` is ill-formed (because `n` is not a constant
299
+ expression).
 
 
 
 
300
 
301
+ The *expression* in a *noptr-new-declarator* is erroneous if:
 
 
 
 
 
 
 
 
 
302
 
303
+ - the expression is of non-class type and its value before converting to
304
+ `std::size_t` is less than zero;
305
+ - the expression is of class type and its value before application of
306
+ the second standard conversion ([[over.ics.user]])[^18] is less than
307
+ zero;
308
+ - its value is such that the size of the allocated object would exceed
309
+ the implementation-defined limit (annex  [[implimits]]); or
310
+ - the *new-initializer* is a *braced-init-list* and the number of array
311
+ elements for which initializers are provided (including the
312
+ terminating `'\0'` in a string literal ([[lex.string]])) exceeds the
313
+ number of elements to initialize.
314
+
315
+ If the *expression*, after converting to `std::size_t`, is a core
316
+ constant expression and the expression is erroneous, the program is
317
+ ill-formed. Otherwise, a *new-expression* with an erroneous expression
318
+ does not call an allocation function and terminates by throwing an
319
+ exception of a type that would match a handler ([[except.handle]]) of
320
+ type `std::bad_array_new_length` ([[new.badlength]]). When the value of
321
+ the *expression* is zero, the allocation function is called to allocate
322
+ an array with no elements.
323
+
324
+ A *new-expression* may obtain storage for the object by calling an
325
  *allocation function* ([[basic.stc.dynamic.allocation]]). If the
326
  *new-expression* terminates by throwing an exception, it may release
327
  storage by calling a deallocation function (
328
  [[basic.stc.dynamic.deallocation]]). If the allocated type is a
329
  non-array type, the allocation function’s name is `operator new` and the
 
341
  if the allocated type is a class type `T` or array thereof, the
342
  allocation function’s name is looked up in the scope of `T`. If this
343
  lookup fails to find the name, or if the allocated type is not a class
344
  type, the allocation function’s name is looked up in the global scope.
345
 
346
+ An implementation is allowed to omit a call to a replaceable global
347
+ allocation function ([[new.delete.single]], [[new.delete.array]]). When
348
+ it does so, the storage is instead provided by the implementation or
349
+ provided by extending the allocation of another *new-expression*. The
350
+ implementation may extend the allocation of a *new-expression* `e1` to
351
+ provide storage for a *new-expression* `e2` if the following would be
352
+ true were the allocation not extended:
353
+
354
+ - the evaluation of `e1` is sequenced before the evaluation of `e2`, and
355
+ - `e2` is evaluated whenever `e1` obtains storage, and
356
+ - both `e1` and `e2` invoke the same replaceable global allocation
357
+ function, and
358
+ - if the allocation function invoked by `e1` and `e2` is throwing, any
359
+ exceptions thrown in the evaluation of either `e1` or `e2` would be
360
+ first caught in the same handler, and
361
+ - the pointer values produced by `e1` and `e2` are operands to evaluated
362
+ *delete-expression*s, and
363
+ - the evaluation of `e2` is sequenced before the evaluation of the
364
+ *delete-expression* whose operand is the pointer value produced by
365
+ `e1`.
366
+
367
+ ``` cpp
368
+ void mergeable(int x) {
369
+ // These allocations are safe for merging:
370
+ std::unique_ptr<char[]> a{new (std::nothrow) char[8]};
371
+ std::unique_ptr<char[]> b{new (std::nothrow) char[8]};
372
+ std::unique_ptr<char[]> c{new (std::nothrow) char[x]};
373
+
374
+ g(a.get(), b.get(), c.get());
375
+ }
376
+
377
+ void unmergeable(int x) {
378
+ std::unique_ptr<char[]> a{new char[8]};
379
+ try {
380
+ // Merging this allocation would change its catch handler.
381
+ std::unique_ptr<char[]> b{new char[x]};
382
+ } catch (const std::bad_alloc& e) {
383
+ std::cerr << "Allocation failed: " << e.what() << std::endl;
384
+ throw;
385
+ }
386
+ }
387
+ ```
388
+
389
+ When a *new-expression* calls an allocation function and that allocation
390
+ has not been extended, the *new-expression* passes the amount of space
391
+ requested to the allocation function as the first argument of type
392
+ `std::size_t`. That argument shall be no less than the size of the
393
+ object being created; it may be greater than the size of the object
394
+ being created only if the object is an array. For arrays of `char` and
395
+ `unsigned char`, the difference between the result of the
396
+ *new-expression* and the address returned by the allocation function
397
+ shall be an integral multiple of the strictest fundamental alignment
398
+ requirement ([[basic.align]]) of any object type whose size is no
399
+ greater than the size of the array being created. Because allocation
400
+ functions are assumed to return pointers to storage that is
401
+ appropriately aligned for objects of any type with fundamental
402
+ alignment, this constraint on array allocation overhead permits the
403
+ common idiom of allocating character arrays into which objects of other
404
+ types will later be placed.
405
+
406
+ When a *new-expression* calls an allocation function and that allocation
407
+ has been extended, the size argument to the allocation call shall be no
408
+ greater than the sum of the sizes for the omitted calls as specified
409
+ above, plus the size for the extended call had it not been extended,
410
+ plus any padding necessary to align the allocated objects within the
411
+ allocated memory.
412
 
413
  The *new-placement* syntax is used to supply additional arguments to an
414
  allocation function. If used, overload resolution is performed on a
415
  function call created by assembling an argument list consisting of the
416
  amount of space requested (the first argument) and the expressions in
 
455
 
456
  A *new-expression* that creates an object of type `T` initializes that
457
  object as follows:
458
 
459
  - If the *new-initializer* is omitted, the object is
460
+ default-initialized ([[dcl.init]]). If no initialization is
461
+ performed, the object has an indeterminate value.
462
  - Otherwise, the *new-initializer* is interpreted according to the
463
  initialization rules of  [[dcl.init]] for direct-initialization.
464
 
465
  The invocation of the allocation function is indeterminately sequenced
466
  with respect to the evaluations of expressions in the *new-initializer*.
 
470
  function returns the null pointer or exits using an exception.
471
 
472
  If the *new-expression* creates an object or an array of objects of
473
  class type, access and ambiguity control are done for the allocation
474
  function, the deallocation function ([[class.free]]), and the
475
+ constructor ([[class.ctor]]). If the *new-expression* creates an array
476
+ of objects of class type, the destructor is potentially invoked (
477
+ [[class.dtor]]).
478
 
479
  If any part of the object initialization described above[^19] terminates
480
+ by throwing an exception, storage has been obtained for the object, and
481
+ a suitable deallocation function can be found, the deallocation function
482
+ is called to free the memory in which the object was being constructed,
483
+ after which the exception continues to propagate in the context of the
484
+ *new-expression*. If no unambiguous matching deallocation function can
485
+ be found, propagating the exception does not cause the object’s memory
486
+ to be freed. This is appropriate when the called allocation function
487
+ does not allocate memory; otherwise, it is likely to result in a memory
488
+ leak.
489
 
490
  If the *new-expression* begins with a unary `::` operator, the
491
  deallocation function’s name is looked up in the global scope.
492
  Otherwise, if the allocated type is a class type `T` or an array
493
  thereof, the deallocation function’s name is looked up in the scope of
 
496
  looked up in the global scope.
497
 
498
  A declaration of a placement deallocation function matches the
499
  declaration of a placement allocation function if it has the same number
500
  of parameters and, after parameter transformations ([[dcl.fct]]), all
501
+ parameter types except the first are identical. If the lookup finds a
502
+ single matching deallocation function, that function will be called;
503
+ otherwise, no deallocation function will be called. If the lookup finds
504
+ the two-parameter form of a usual deallocation function (
505
+ [[basic.stc.dynamic.deallocation]]) and that function, considered as a
506
+ placement deallocation function, would have been selected as a match for
507
+ the allocation function, the program is ill-formed. For a non-placement
508
+ allocation function, the normal deallocation function lookup is used to
509
+ find the matching deallocation function ([[expr.delete]])
510
 
511
  ``` cpp
512
  struct S {
513
  // Placement allocation function:
514
  static void* operator new(std::size_t, std::size_t);
 
545
  ```
546
 
547
  The first alternative is for non-array objects, and the second is for
548
  arrays. Whenever the `delete` keyword is immediately followed by empty
549
  square brackets, it shall be interpreted as the second alternative.[^20]
550
+ The operand shall be of pointer to object type or of class type. If of
551
+ class type, the operand is contextually implicitly converted (Clause 
552
+ [[conv]]) to a pointer to object type.[^21] The *delete-expression*’s
553
+ result has type `void`.
554
 
555
  If the operand has a class type, the operand is converted to a pointer
556
  type by calling the above-mentioned conversion function, and the
557
  converted operand is used in place of the original operand for the
558
  remainder of this section. In the first alternative (*delete object*),
 
591
  case of an array, the elements will be destroyed in order of decreasing
592
  address (that is, in reverse order of the completion of their
593
  constructor; see  [[class.base.init]]).
594
 
595
  If the value of the operand of the *delete-expression* is not a null
596
+ pointer value, then:
597
+
598
+ - If the allocation call for the *new-expression* for the object to be
599
+ deleted was not omitted and the allocation was not extended (
600
+ [[expr.new]]), the *delete-expression* shall call a deallocation
601
+ function ([[basic.stc.dynamic.deallocation]]). The value returned
602
+ from the allocation call of the *new-expression* shall be passed as
603
+ the first argument to the deallocation function.
604
+ - Otherwise, if the allocation was extended or was provided by extending
605
+ the allocation of another *new-expression*, and the
606
+ *delete-expression* for every other pointer value produced by a
607
+ *new-expression* that had storage provided by the extended
608
+ *new-expression* has been evaluated, the *delete-expression* shall
609
+ call a deallocation function. The value returned from the allocation
610
+ call of the extended *new-expression* shall be passed as the first
611
+ argument to the deallocation function.
612
+ - Otherwise, the *delete-expression* will not call a *deallocation
613
+ function* ([[basic.stc.dynamic.deallocation]]).
614
+
615
+ Otherwise, it is unspecified whether the deallocation function will be
616
+ called. The deallocation function is called regardless of whether the
617
+ destructor for the object or some element of the array throws an
618
+ exception.
619
 
620
  An implementation provides default definitions of the global
621
  deallocation functions `operator delete()` for non-arrays (
622
  [[new.delete.single]]) and `operator delete[]()` for arrays (
623
  [[new.delete.array]]). A C++ program can provide alternative definitions
624
  of these functions ([[replacement.functions]]), and/or class-specific
625
  versions ([[class.free]]).
626
 
627
  When the keyword `delete` in a *delete-expression* is preceded by the
628
+ unary `::` operator, the deallocation function’s name is looked up in
629
+ global scope. Otherwise, the lookup considers class-specific
630
+ deallocation functions ([[class.free]]). If no class-specific
631
+ deallocation function is found, the deallocation function’s name is
632
+ looked up in global scope.
633
+
634
+ If the type is complete and if deallocation function lookup finds both a
635
+ usual deallocation function with only a pointer parameter and a usual
636
+ deallocation function with both a pointer parameter and a size
637
+ parameter, then the selected deallocation function shall be the one with
638
+ two parameters. Otherwise, the selected deallocation function shall be
639
+ the function with one parameter.
640
+
641
+ When a *delete-expression* is executed, the selected deallocation
642
+ function shall be called with the address of the block of storage to be
643
+ reclaimed as its first argument and (if the two-parameter deallocation
644
+ function is used) the size of the block as its second argument.[^23]
645
 
646
  Access and ambiguity control are done for both the deallocation function
647
  and the destructor ([[class.dtor]],  [[class.free]]).
648
 
649
  ### Alignof <a id="expr.alignof">[[expr.alignof]]</a>
650
 
651
  An `alignof` expression yields the alignment requirement of its operand
652
  type. The operand shall be a *type-id* representing a complete object
653
+ type, or an array thereof, or a reference to one of those types.
654
 
655
  The result is an integral constant of type `std::size_t`.
656
 
657
+ When `alignof` is applied to a reference type, the result is the
658
  alignment of the referenced type. When `alignof` is applied to an array
659
+ type, the result is the alignment of the element type.
660
 
661
  ### `noexcept` operator <a id="expr.unary.noexcept">[[expr.unary.noexcept]]</a>
662
 
663
  The `noexcept` operator determines whether the evaluation of its
664
  operand, which is an unevaluated operand (Clause  [[expr]]), can throw
 
668
  noexcept-expression:
669
  'noexcept' '(' expression ')'
670
  ```
671
 
672
  The result of the `noexcept` operator is a constant of type `bool` and
673
+ is a prvalue.
674
 
675
  The result of the `noexcept` operator is `false` if in a
676
  potentially-evaluated context the *expression* would contain
677
 
678
+ - a potentially-evaluated call[^24] to a function, member function,
679
  function pointer, or member function pointer that does not have a
680
  non-throwing *exception-specification* ([[except.spec]]), unless the
681
  call is a constant expression ([[expr.const]]),
682
+ - a potentially-evaluated *throw-expression* ([[except.throw]]),
683
+ - a potentially-evaluated `dynamic_cast` expression
684
  `dynamic_cast<T>(v)`, where `T` is a reference type, that requires a
685
  run-time check ([[expr.dynamic.cast]]), or
686
+ - a potentially-evaluated `typeid` expression ([[expr.typeid]]) applied
687
  to a glvalue expression whose type is a polymorphic class type (
688
  [[class.virtual]]).
689
 
690
  Otherwise, the result is `true`.
691