#include <iostream.h>
#include <windows.h>
int
main(int, char **)
{
int *ptr = new int[2];
ptr[0] = 0;
ptr[1] = 1;
delete[] ptr; //Bug: put here accidentally instead of after for() loop below
for (int i=0; i < 2; i++) {
//FMR: these access memory which was already deallocated
cerr << "element #" << i << " is " << ptr[i] << '\n';
}
return(0);
}
(C) Copyright IBM Corporation 1992, 2010.