C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Fwd: set_new_handler extension

From: Thiago Macieira <thiago_at_[hidden]>
Date: Mon, 20 Feb 2023 13:08:27 -0800
On Monday, 20 February 2023 11:51:10 PST Julien Villemure-Fréchette via Std-
Proposals wrote:
> global operator new and delete can be replaced by a non inline, non static
> global operator new with equivalent signature; any uses of a new/delete
> expression (with equivalent signature) or direct call to operator
> new/delete from anywhere, including the standard library, will pick the
> user definition, no declaration of this replacement need to be in scope
> (ie, it is always implicitly visible, as would be the default
> implementation provided by the standard library).

The standard does not guarantee that. You can only replace operator new if the
replacement definition can be seen.

There's no such thing as "global definition" on Windows DLLs. The definition is
determined at link time to find which DLL provides this symbol, then can't be
changed short of relinking.

> Note: As explained in the specification, providing a single replacement for
> `operator new(size_t)` and `operator `delete(void*)` is sufficient to cover
> all non alignment-aware overloads.

It is, for most uses. For most people, this is sufficient.

I don't think Phil's case counts as "most people".

-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel DCAI Cloud Engineering

Received on 2023-02-20 21:08:29