From Jason Turner

[basic.stc.dynamic.allocation]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpwdrmqbqi/{from.md → to.md} +34 -26
tmp/tmpwdrmqbqi/{from.md → to.md} RENAMED
@@ -18,38 +18,46 @@ storage. If it is successful, it shall return the address of the start
18
  of a block of storage whose length in bytes shall be at least as large
19
  as the requested size. There are no constraints on the contents of the
20
  allocated storage on return from the allocation function. The order,
21
  contiguity, and initial value of storage allocated by successive calls
22
  to an allocation function are unspecified. The pointer returned shall be
23
- suitably aligned so that it can be converted to a pointer of any
24
- complete object type with a fundamental alignment requirement (
25
- [[basic.align]]) and then used to access the object or array in the
26
- storage allocated (until the storage is explicitly deallocated by a call
27
- to a corresponding deallocation function). Even if the size of the space
28
- requested is zero, the request can fail. If the request succeeds, the
29
- value returned shall be a non-null pointer value ([[conv.ptr]]) `p0`
30
- different from any previously returned value `p1`, unless that value
31
- `p1` was subsequently passed to an `operator` `delete`. The effect of
32
- indirecting through a pointer returned as a request for zero size is
33
- undefined.[^12]
 
 
 
34
 
35
  An allocation function that fails to allocate storage can invoke the
36
- currently installed new-handler function ([[new.handler]]), if any. A
37
- program-supplied allocation function can obtain the address of the
38
- currently installed `new_handler` using the `std::get_new_handler`
39
- function ([[set.new.handler]]). If an allocation function declared with
40
- a non-throwing *exception-specification* ([[except.spec]]) fails to
41
- allocate storage, it shall return a null pointer. Any other allocation
42
- function that fails to allocate storage shall indicate failure only by
43
- throwing an exception ([[except.throw]]) of a type that would match a
44
- handler ([[except.handle]]) of type `std::bad_alloc` ([[bad.alloc]]).
 
 
 
45
 
46
  A global allocation function is only called as the result of a new
47
  expression ([[expr.new]]), or called directly using the function call
48
  syntax ([[expr.call]]), or called indirectly through calls to the
49
- functions in the C++standard library. In particular, a global allocation
50
- function is not called to allocate storage for objects with static
51
- storage duration ([[basic.stc.static]]), for objects or references with
52
- thread storage duration ([[basic.stc.thread]]), for objects of type
53
- `std::type_info` ([[expr.typeid]]), or for an exception object (
54
- [[except.throw]]).
 
 
55
 
 
18
  of a block of storage whose length in bytes shall be at least as large
19
  as the requested size. There are no constraints on the contents of the
20
  allocated storage on return from the allocation function. The order,
21
  contiguity, and initial value of storage allocated by successive calls
22
  to an allocation function are unspecified. The pointer returned shall be
23
+ suitably aligned so that it can be converted to a pointer to any
24
+ suitable complete object type ([[new.delete.single]]) and then used to
25
+ access the object or array in the storage allocated (until the storage
26
+ is explicitly deallocated by a call to a corresponding deallocation
27
+ function). Even if the size of the space requested is zero, the request
28
+ can fail. If the request succeeds, the value returned shall be a
29
+ non-null pointer value ([[conv.ptr]]) `p0` different from any
30
+ previously returned value `p1`, unless that value `p1` was subsequently
31
+ passed to an `operator` `delete`. Furthermore, for the library
32
+ allocation functions in  [[new.delete.single]] and 
33
+ [[new.delete.array]], `p0` shall represent the address of a block of
34
+ storage disjoint from the storage for any other object accessible to the
35
+ caller. The effect of indirecting through a pointer returned as a
36
+ request for zero size is undefined.[^13]
37
 
38
  An allocation function that fails to allocate storage can invoke the
39
+ currently installed new-handler function ([[new.handler]]), if any.
40
+
41
+ [*Note 1*: A program-supplied allocation function can obtain the
42
+ address of the currently installed `new_handler` using the
43
+ `std::get_new_handler` function ([[set.new.handler]]). *end note*]
44
+
45
+ If an allocation function that has a non-throwing exception
46
+ specification ([[except.spec]]) fails to allocate storage, it shall
47
+ return a null pointer. Any other allocation function that fails to
48
+ allocate storage shall indicate failure only by throwing an exception (
49
+ [[except.throw]]) of a type that would match a handler (
50
+ [[except.handle]]) of type `std::bad_alloc` ([[bad.alloc]]).
51
 
52
  A global allocation function is only called as the result of a new
53
  expression ([[expr.new]]), or called directly using the function call
54
  syntax ([[expr.call]]), or called indirectly through calls to the
55
+ functions in the C++standard library.
56
+
57
+ [*Note 2*: In particular, a global allocation function is not called to
58
+ allocate storage for objects with static storage duration (
59
+ [[basic.stc.static]]), for objects or references with thread storage
60
+ duration ([[basic.stc.thread]]), for objects of type `std::type_info` (
61
+ [[expr.typeid]]), or for an exception object (
62
+ [[except.throw]]). — *end note*]
63