数组下标为-1不会crash 发现在栈上的指针可以随意乱动,这就会导致出现“写坏内存”的情况。今天大开眼界。
#include <iostream>using namespace std;struct TestClass{int* pointer;};int main(){TestClass* a =new TestClass();a->pointer = new int[10];std::cout<<a->pointer[-1]<<endl;return 0;}