Title
May a replacement allocation function be declared inline?
Status
cd1
Section
[replacement.functions] [new.delete]
Submitter
Matt Austern

Created on 2003-04-24.00:00:00 last changed 171 months ago

Messages

Date: 2010-10-21.18:28:33

Rationale:

The fact that inline isn't mentioned appears to have been nothing more than an oversight. Existing implementations do not permit inline functions as replacement memory allocation functions. Providing this functionality would be difficult in some cases, and is believed to be of limited value.

Date: 2010-10-21.18:28:33

[ Kona: added "no diagnostic is required" ]

Date: 2010-10-21.18:28:33

Proposed resolution:

Add a new sentence to the end of [replacement.functions] paragraph 3: "The program's definitions shall not be specified as inline. No diagnostic is required."

Date: 2003-04-24.00:00:00

The eight basic dynamic memory allocation functions (single-object and array versions of ::operator new and ::operator delete, in the ordinary and nothrow forms) are replaceable. A C++ program may provide an alternative definition for any of them, which will be used in preference to the implementation's definition.

Three different parts of the standard mention requirements on replacement functions: [replacement.functions], [new.delete.single] and [new.delete.array], and [basic.stc.auto].

None of these three places say whether a replacement function may be declared inline. [new.delete.single] paragraph 2 specifies a signature for the replacement function, but that's not enough: the inline specifier is not part of a function's signature. One might also reason from [dcl.fct.spec] paragraph 2, which requires that "an inline function shall be defined in every translation unit in which it is used," but this may not be quite specific enough either. We should either explicitly allow or explicitly forbid inline replacement memory allocation functions.

History
Date User Action Args
2010-10-21 18:28:33adminsetmessages: + msg2505
2010-10-21 18:28:33adminsetmessages: + msg2504
2010-10-21 18:28:33adminsetmessages: + msg2503
2003-04-24 00:00:00admincreate