Created on 2014-04-12.00:00:00 last changed 47 months ago
Proposed resolution (November, 2017)
Change 6.7.5.5 [basic.stc.dynamic] paragraph 3 as follows:
Any allocation and/or deallocation functions defined in a C ++ program, including the default versions in the library, shall conform to the semanticsIf the behavior of an allocation or deallocation function does not satisfy the semantic constraints specified in 6.7.5.5.2 [basic.stc.dynamic.allocation] and 6.7.5.5.3 [basic.stc.dynamic.deallocation], the behavior is undefined.
Change 6.7.5.5.2 [basic.stc.dynamic.allocation] paragraph 1 as follows:
...The value of the first parametershall beis interpreted as the requested size of the allocation...
Change 6.7.5.5.2 [basic.stc.dynamic.allocation] paragraph 2 as follows:
TheAn allocation function attempts to allocate the requested amount of storage. If it is successful, itshall returnreturns the address of the start of a block of storage whose length in bytesshall beis at least as large as the requested size.There are no constraints on the contents of the allocated storage on return from the allocation function.The order, contiguity, and initial value of storage allocated by successive calls to an allocation function are unspecified.TheFor an allocation function other than a reserved placement allocation function (17.6.3.4 [new.delete.placement], the pointer returnedshall beis suitably aligned so that it can be converted to a pointer to any suitable complete object type (17.6.3.2 [new.delete.single]) and then used to access the object or array in the storage allocated (until the storage is explicitly deallocated by a call to a corresponding deallocation function). Even if the size of the space requested is zero, the request can fail. If the request succeeds, the value returnedshall beby a replaceable allocation function is a non-null pointer value (7.3.12 [conv.ptr]) p0 different from any previously returned value p1, unless that value p1 was subsequently passed toan operator deletea replaceable deallocation function. Furthermore, for the library allocation functions in 17.6.3.2 [new.delete.single] and 17.6.3.3 [new.delete.array], p0shall representrepresents the address of a block of storage disjoint from the storage for any other object accessible to the caller. The effect of indirecting through a pointer returnedasfrom a request for zero size is undefined.38
Change 6.7.5.5.2 [basic.stc.dynamic.allocation] paragraph 3 as follows:
An allocation function that fails to allocate storage can invoke the currently installed new-handler function (17.6.4.3 [new.handler]), if any. [Note: A program-supplied allocation function can obtain the address of the currently installed new_handler using the std::get_new_handler function (17.6.4.4 [set.new.handler]). —end note]If anAn allocation function that has a non-throwing exception specification (14.5 [except.spec])fails to allocate storage, it shall returnindicates failure by returning a null pointer value. Any other allocation functionthat fails to allocate storage shall indicatenever returns a null pointer value and indicates failure only by throwing an exception (14.2 [except.throw]) of a type that would match a handler (14.4 [except.handle]) of type std::bad_alloc (17.6.4.1 [bad.alloc]).
[Accepted as a DR at the March, 2018 (Jacksonville) meeting.]
According to 6.7.5.5.2 [basic.stc.dynamic.allocation] paragraph 3,
If an allocation function declared with a non-throwing exception-specification (14.5 [except.spec]) fails to allocate storage, it shall return a null pointer. Any other allocation function that fails to allocate storage shall indicate failure only by throwing an exception (14.2 [except.throw]) of a type that would match a handler (14.4 [except.handle]) of type std::bad_alloc (17.6.4.1 [bad.alloc]).
The use of the word “shall” to constrain runtime behavior is inappropriate, as it normally identifies cases requiring a compile-time diagnostic.
History | |||
---|---|---|---|
Date | User | Action | Args |
2020-12-15 00:00:00 | admin | set | status: dr -> cd5 |
2018-04-11 00:00:00 | admin | set | status: tentatively ready -> dr |
2018-02-27 00:00:00 | admin | set | messages: + msg5852 |
2018-02-27 00:00:00 | admin | set | status: drafting -> tentatively ready |
2014-07-07 00:00:00 | admin | set | status: open -> drafting |
2014-04-12 00:00:00 | admin | create |