I attached a program with an obvious mistake:
int *ivar = new int(12);
int *ivar = new int;
Also in the end, there is line delete  ivar;.
The program complies well by gcc 4.2.2 (Xcode) and works "fine". No warnings. No crash.
I thought, there is only one variable in this program and so there is nothing to crash. I added few other variables - no crash at all. :( I compiled it manually in a terminal session :) - same result.
Same program in Visual Studio is complied well (no warnings), but an exception raised in the debug session -"Microsoft C++ exception: std::bad_alloc at memory location...". It was not because of the "delete  ivar;" line. It is in the second loop, in "std::cout << ivar[k];. Actually, almost any touch, a try to read this 'ivar' in VS, causes a crash.
So this code (attached) is correct from the compiler point of view?
How you, guys, detect such memory problems, if you don't work with VS?
Is it again a problem/bug in the gcc from Apple?
int main (int argc, char * const argv)
int * ivar = new int(12);
for (int i = 0; i < 12; ++i)
ivar[i] = i;
for (int k = 0; k < 12; ++k)
std::cout << "[" << k << "] = " << ivar[k] << "\n";
delete  ivar;