1) Compiler dependent on Mac OS with gcc 4.0.1:
g++ -Wall -g -c main.cpp -o main.o g++ -ox main.o ./x I am doing ok ... I am doing ok ... x(5857) malloc: *** error for object 0x100150: double free *** set a breakpoint in malloc_error_break to debug I am doing ok ...
Double free causes problems.
2) Usually, deleting a pointer that has already been deleted is not indicated, you should always point to 0 after deletion, allowing the pointer to be deleted with a value of 0.
3) The reason that it can still print a line is because the pointer still points to freed memory, but I would assume that only the pointer is fixed, for example. It is returned to the free pool for reuse, the memory is not overwritten or duplicated, so if you search for a pointer, you will still get the original values, unless the memory is reused.
stefanB
source share