This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


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

operator new with placement


Hiya,

I deperately need new with placement, but gcc-2.95.1 refuses
to compile it.

The (latest draft) standard that I got says:

18.4.1.3  Placement forms                   [lib.new.delete.placement]

1 These  functions  are reserved, a C++ program may not define functions
  that displace the versions in  the  Standard  C++  library  (_lib.con-
  straints_).

  void* operator new(std::size_t size, void* ptr) throw();

  Returns:
    ptr.
  Notes:
    Intentionally performs no other action.

2 [Example:  This  can  be  useful for constructing an object at a known
  address:
  char place[sizeof(Something)];
  Something* p = new (place) Something();
   --end example]

But when I try to compile this:
--------------------------
class Something {
};

char place[sizeof(Something)];

int main(void)
{
  Something* p = new (place) Something();
  return 0;
}
--------------------------
I get:
--------------------------
~/c++/tests>g++ placement.cc
placement.cc: In function `int main()':
<internal>:8: too many arguments to function `void * operator new(unsigned int)'
placement.cc:8: at this point in file

Bug? Or did the standard change since the draft I got?

-- 
 Carlo Wood  <carlo@runaway.xs4all.nl>

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