--- In [email protected], Tyler Littlefield <ty...@...> wrote: > > Second, you allocate a block of memory of 40 bytes, or 10 integers
Actaully the OP only allocates space for 10 bytes, not integers. Hence even i[2] consists partly of unallocated memory. The reason you aren't seeing a crash is that the compiler (actually it will be the OS) has probably allocated a larger block of memory than you asked for, and there aren't any additional run-time checks that might detect the invalid accesses. The program is still wrong however, and in fact I do see a crash when free() is called on my system (linux, g++). Using malloc() it should be: i = (int *)malloc((SIZE + EXTRA) * sizeof(int)); But as Tyler says, in C++ you should be using new().
