J
jjleto
Hello,
How do I handle the following :
------>
#include <iostream>
using namespace std;
int main()
{
int n = 0x7FFFFFFF;
char *pp = new char(n);
if ( pp != NULL ) {
pp[0] = 0;
pp[n-1] = 0;
cout << "OK" << endl;
} else {
cout << "FAILED" << endl;
}
}
------>
It compiles OK, but when I run it, I get a segmentation fault. I thought
that testing a NULL value was enough for testing memory allocation (or
perhaps it is a bug ? I use gcc (GCC) 3.3.4)
Regards,
jjleto
How do I handle the following :
------>
#include <iostream>
using namespace std;
int main()
{
int n = 0x7FFFFFFF;
char *pp = new char(n);
if ( pp != NULL ) {
pp[0] = 0;
pp[n-1] = 0;
cout << "OK" << endl;
} else {
cout << "FAILED" << endl;
}
}
------>
It compiles OK, but when I run it, I get a segmentation fault. I thought
that testing a NULL value was enough for testing memory allocation (or
perhaps it is a bug ? I use gcc (GCC) 3.3.4)
Regards,
jjleto