[VC++ .NET 2003] BUG: operator delete[](void*, size_t) broken
From: Alberto Barbati (AlbertoBarbati_at_libero.it)
Date: 03/05/04
- Next message: MattC: "Re: Getting Thead ID"
- Previous message: Hendrik Schober: "Re: [VC++.NET] Invoking an executable which takes arguments"
- Next in thread: Carl Daniel [VC++ MVP]: "Re: [VC++ .NET 2003] BUG: operator delete[](void*, size_t) broken"
- Reply: Carl Daniel [VC++ MVP]: "Re: [VC++ .NET 2003] BUG: operator delete[](void*, size_t) broken"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 05 Mar 2004 11:41:14 GMT
Hi,
when operator delete[] is declared with two parameters void* and size_t,
the value of the second parameter should be the size of the allocated
block (12.5/5). This is incorrectly implemented in VC++ .NET 2003.
Given the following test program:
------------ Test.cpp
#include <iostream>
class Test
{
public:
Test() {}
~Test() {}
void* operator new[](std::size_t n)
{
std::cout << "new [" << n << "]\n";
return ::operator new(n * 10);
}
void operator delete[](void* p, std::size_t n)
{
std::cout << "delete [" << n << "]\n";
return ::operator delete(p);
}
private:
int a, b, c;
};
int main(int argc, char* argv[])
{
Test* t = new Test[10];
delete[] t;
}
------------ end Test.cpp
The output should be:
new [124]
delete [124]
(and that's exactly what I get with GCC 3.3.1). Instead VC++ gives:
new [124]
delete [12]
notice that the value of the second argument in delete[] is the size of
the class and not the size of the block.
Regards,
Alberto Barbati
- Next message: MattC: "Re: Getting Thead ID"
- Previous message: Hendrik Schober: "Re: [VC++.NET] Invoking an executable which takes arguments"
- Next in thread: Carl Daniel [VC++ MVP]: "Re: [VC++ .NET 2003] BUG: operator delete[](void*, size_t) broken"
- Reply: Carl Daniel [VC++ MVP]: "Re: [VC++ .NET 2003] BUG: operator delete[](void*, size_t) broken"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|