Re: This HAS to be UB...
Chris M. Thomasson wrote:
Keep in mind that I am a C programmer; well, anyway here is the C++
program...
[..]
On GCC I get the following output:
custom_allocator::allocate(00246C50, 2234)
custom_allocator::deallocate(00246C50, 2234)
custom_allocator::allocate(00247760, 11174)
custom_allocator::deallocate(00247760, 11174)
On MSVC 8 I get:
custom_allocator::allocate(00362850, 2234)
custom_allocator::deallocate(00362850, 2234)
custom_allocator::allocate(00366B68, 11170)
custom_allocator::deallocate(00366B68, 2234)
MSVC 9 gives the same output, BTW.
Are they both right due to UB? WTF is going on? GCC seems to be accurate
at least... DAMN!
Well, the default implementation of the operator delete[] does *not*
have the "size" argument. In fact there are two allowed declarations of
the operator delete[]:
void operator delete[](void* ptr) throw();
and
void operator delete[](void* ptr, const std::nothrow&) throw();
I'm not sure what else to tell you.
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask