H
Howard Hinnant
Hello,
I'm writing a brief paper on LWG issue 206:
http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#206
It would help me immensely if I knew more about the current practice of
several vendors. I am asking for volunteers to post the results of the
following short program, along with the compiler (including version)
which produced those results. To get the ball rolling, here are results
I'm aware of:
CodeWarrior Pro 7-10:
custom allocation
custom deallocation
custom allocation
custom deallocation
gcc 4.0.1 on Mac OS X*:
custom allocation
custom deallocation
custom allocation
custom deallocation
* For the above results on gcc/Mac I had to add the following line to
the program which concerns a side issue I'm not addressing herein:
__attribute__((__weak__, __visibility__("default"))) int
dummy_weak_symbol_for_new;
Below is the test. Thank you in advance.
Howard Hinnant
----------------
#include <cstdio>
#include <cstdlib>
#include <new>
void* operator new(std::size_t size) throw(std::bad_alloc)
{
std:rintf("custom allocation\n");
if (size == 0)
size = 1;
void*p = std::malloc(size);
if (p == 0)
throw std::bad_alloc();
return p;
}
void operator delete(void* ptr) throw()
{
std:rintf("custom deallocation\n");
std::free(ptr);
}
int main()
{
int* i = new int;
delete i;
int* a = new int[3];
delete [] a;
}
I'm writing a brief paper on LWG issue 206:
http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#206
It would help me immensely if I knew more about the current practice of
several vendors. I am asking for volunteers to post the results of the
following short program, along with the compiler (including version)
which produced those results. To get the ball rolling, here are results
I'm aware of:
CodeWarrior Pro 7-10:
custom allocation
custom deallocation
custom allocation
custom deallocation
gcc 4.0.1 on Mac OS X*:
custom allocation
custom deallocation
custom allocation
custom deallocation
* For the above results on gcc/Mac I had to add the following line to
the program which concerns a side issue I'm not addressing herein:
__attribute__((__weak__, __visibility__("default"))) int
dummy_weak_symbol_for_new;
Below is the test. Thank you in advance.
Howard Hinnant
----------------
#include <cstdio>
#include <cstdlib>
#include <new>
void* operator new(std::size_t size) throw(std::bad_alloc)
{
std:rintf("custom allocation\n");
if (size == 0)
size = 1;
void*p = std::malloc(size);
if (p == 0)
throw std::bad_alloc();
return p;
}
void operator delete(void* ptr) throw()
{
std:rintf("custom deallocation\n");
std::free(ptr);
}
int main()
{
int* i = new int;
delete i;
int* a = new int[3];
delete [] a;
}