3
我已经将其设置为1启用MALLOC_CHECK_
(试图与2和3也一样),但我不认为它报告任何问题与下面的C++程序:MALLOC_CHECK_不报告违规
int n = atoi(argv[1]);
std::cout<<"n = "<<n<<std::endl;
char *buf = new char[n];
for (int i = 0;i < n*n; i++)
{
buf++;
*buf = 'x';
}
std::cout<<"done"<<std::endl;
上午我在这里丢失什么?
你没有做'malloc'。 – Naveen
'char * buf =(char *)malloc(n);' – Maroun
operator new可以调用malloc。在我的环境中(libstdC++)它是[link](http://gcc.gnu.org/viewcvs/trunk/libstdc%2B%2B-v3/libsupc%2B%2B/new_op.cc?revision=193295&view=markup ) – user947158