#include <stdio.h>
#include <stdlib.h>

class Node{
         int a;
         int b;

extern "C" void demoNew(void) {
         Node *n0 = new Node;
         Node *n1 = (Node *)new char[sizeof(Node)];
         printf("no=%p n1=%p\n", n0, n1);
         delete n0;
         delete[] n1;

int main(int argc, char ** argv) {
         return 0;

For reference and comparison, on x86_64 Linux with
   g++ (GCC) 6.4.1 20170727 (Red Hat 6.4.1-1)

the relevant interceptions are
--13225-- REDIR: 0x4ec9a80 (libstdc++.so.6:operator new(unsigned long)) 
redirected to 0x4c2e18e (operator new(unsigned long))
--13225-- REDIR: 0x4ec9b40 (libstdc++.so.6:operator new[](unsigned long)) 
redirected to 0x4c2e87b (operator new[](unsigned long))

--13225-- REDIR: 0x4ec7a70 (libstdc++.so.6:operator delete(void*)) redirected 
to 0x4c2f1ac (operator delete(void*))
--13225-- REDIR: 0x4ec7aa0 (libstdc++.so.6:operator delete[](void*)) redirected 
to 0x4c2f67c (operator delete[](void*))

and valgrind does not complain about anything.

Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
Valgrind-users mailing list

Reply via email to