c++ - Valgrind claiming I am using malloc when using new -


Running Valgring against the current codebase, I am getting many "merging free / delete / delete []" errors.

Many of them are repeating a problem: it claims that a delete operation is being used on line XXX, while using a malloc operation on YYY However, when I open that file which he complains and navigates on line numbers, So I think the memory was not allocated with malloc , but with new . Allocated object was a standard ifstream and neither was the use of new [] and delete [] .

Valgrind 3.5 is running. Do anyone know what's going on? I can not see how this can be a real error, but I have noticed that some people believe that Valgrind does not do many false positives, so I have some confidence that it is a fake before pressing it .

You do not provide a sample program, so this is a crystal ball guess.

Your program provides a operator new but it does not have delete operator . The following sample program generates the same error message you are seeing:

  #include & lt; New & gt; # Include & lt; Cstdlib & gt; / * * Sample program that provides `operator new`, but not 'operator deleted'. * / / Minimum version for the purpose of minimum purpose only * zero * operator new (size_t numbytes) {return malloc (numBytes); } Int main () {int * p = new int; Remove p; }    

Comments