ftmemsim-valgrind/memcheck/tests/new_nothrow.cpp
Nicholas Nethercote e5cca0566e Added interceptions for:
operator new(unsigned, std::nothrow_t const&)
  operator new[](unsigned, std::nothrow_t const&)

because they weren't being intercepted, and called malloc(), which caused bogus
mismatch errors.

Added a regression test for it, too.

MERGE TO STABLE (although the change to vg_replace_malloc.c won't quite be a
cut and paste job, because of prior changes made to it in the head
but not the stable branch;  merge will still be easy, though)


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1899
2003-10-09 15:40:38 +00:00

14 lines
298 B
C++

#include <new>
// At one point, Valgrind wasn't overriding these 'nothrow' versions; since
// they call malloc(), the calls to 'delete' caused bogus mismatch errors.
int main()
{
int * a = new (std::nothrow) int;
int * b = new (std::nothrow) int[5];
delete a;
delete [] b;
}