This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/12238] placement delete not called on incomplete object construction if in try-block!
- From: "rmerkert at alphatech dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 31 Dec 2003 02:39:58 -0000
- Subject: [Bug c++/12238] placement delete not called on incomplete object construction if in try-block!
- References: <20030910154242.12238.noways@aliceposta.it>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Additional Comments From rmerkert at alphatech dot com 2003-12-31 02:39 -------
I think the code is not correct:
The corresponding placement delete for new (size_t, allocator) should be
delete (void*,allocator) and not delete(void*,size_t,allocator).
Here's a simplified version of the code (I've omitted the array version, and the
placement operators are global):
#include <cstdlib>
#define BUG
struct A
{
A() { throw 1; }
};
void* operator new(::size_t,double)
{
static char memory[64];
return memory;
}
#ifdef BUG
void operator delete(void*,size_t,double)
#else
void operator delete(void*,double)
#endif
{
::std::exit(0);
}
int main()
{
try
{
new(0.0) A();
}
catch(...)
{}
::std::abort();
}
If the incorrect placement delete is used, then no delete function is invoked
whatsoever. Maybe a warning is in order?
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12238