Segmentation fault inside a call to the 'new' operator
Maurizio Umberto Puxeddu
umbpux@tin.it
Sat Jun 26 18:30:00 GMT 1999
Ciao!
Marilyn Davis wrote:
>
> When this has happened to me using gcc, it was because I was writing
> outside the memory previously assigned to me by a previous call to
> new.
>
> If this is what's happening to you, it can be very hard to track down.
>
> Check the steps since the last call to new that worked.
>
> Good luck.
Thanks Marilyn, but I think that my post was not clear enough.
The problem is that if I write something like this
{
const int N = 1024;
// ...
double *p;
cout << "before\n";
p = new double[N];
cout << "after\n";
// ...
}
I get the first message ("before") and then the "segmentation fault"
message. The "after" message is not printed. So the crash happens
_inside_ the call to the new operator. Using a debugger confirms my
suspects.
I hope I've been a bit clearer despite of my bad english. :)
Umberto
More information about the Gcc
mailing list