#include <iostream>
using namespace std;
int main (int args, char **argv) {
char *data = new char(16);
for (int i = 0; i < 16; ++i) {
data[i] = i; // works fine when commented out, also fails when data[i] = 0
}
char *res = new char (10);
delete[] res;
return 0;
}
给出错误,请自行查看:http: //ideone.com/AgZhZB
*** glibc detected *** ./a.out: free(): invalid next size (fast): 0x09377018 ***
======= Backtrace: =========
/lib/i386-linux-gnu/libc.so.6(+0x75ee2)[0xb7519ee2]
/usr/lib/i386-linux-gnu/libstdc++.so.6(_ZdlPv+0x1f)[0xb76f751f]
/usr/lib/i386-linux-gnu/libstdc++.so.6(_ZdaPv+0x1b)[0xb76f757b]
./a.out[0x80485af]
/lib/i386-linux-gnu/libc.so.6(__libc_start_main+0xf3)[0xb74bd4d3]
./a.out[0x80484b1]
我一无所知。任何帮助将非常感激。