This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Add configure flag for operator new (std::nothrow)


On Nov 3, 2015, at 1:10 PM, Martin Sebor <msebor@gmail.com> wrote:
> The "as if" requirement implies that any observable effects of
> "the (possibly replaced) ordinary version" must be preserved.
> The repeated calls to the new handler are among such effects.

Unless the standard is fixed to say that one cannot observe the repeated calls.  We do this in some places, for some things:

15Whenever  a temporary class object is copied using a copy constructor,
  and this object and the copy have the  same  cv-unqualified  type,  an
  implementation  is permitted to treat the original and the copy as two
  different ways of referring to the same object and not perform a  copy
  at  all,  even  if  the class copy constructor or destructor have side
  effects.  For a function with a class return type, if  the  expression
  in  the  return  statement  is the name of a local object, and the cv-
  unqualified type of the local object  is  the  same  as  the  function
  return  type, an implementation is permitted to omit creating the tem-
  porary object to hold the function return value,  even  if  the  class
  copy  constructor or destructor has side effects.  In these cases, the
  object is destroyed at the later of times when the  original  and  the
  copy would have been destroyed without the optimization.111)

in C++, so, it isn’t out of the question.  I was looking for dynamic -> static object optimization wording, but didn’t find it in the first C++ standard.  That is a fairly reasonable thing to do, and if done well, can reasonably change the observable side-effects as well.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]