[libcxx] Patch/RFC: Avoid using ::operator new in the default allocator

Howard Hinnant howard.hinnant at gmail.com
Wed Sep 25 13:47:33 PDT 2013

On Sep 25, 2013, at 3:33 PM, Chandler Carruth <chandlerc at google.com> wrote:

> On Wed, Sep 25, 2013 at 3:29 PM, Howard Hinnant <howard.hinnant at gmail.com> wrote:
> [allocator.members]/p6:
> > Remark: the storage is obtained by calling ::operator new(std::size_t) (18.6.1), but it is unspec- ified when or how often this function is called. The use of hint is unspecified, but intended as an aid to locality if an implementation so desires.
> The question becomes, if we make this substitution, is there a test the user can write to observe it?  Is there an LWG issue here?
> I *believe* that by writing a new expression, you get *precisely* this behavior: storage is obtained by calling ::operator new, but when or how often can change via the implementation (N3664).

Doesn't new char[n] have to call ::operator new[](n) instead of ::operator new(n)?  These two operators are separately overloadable by the client.


If we switch, I think the wrong operator new gets called, and the user can detect that.


More information about the cfe-commits mailing list