#include <iostream>
#include <memory>
#include <cstdlib>
int g_buf[4000];
void test1() {
for (int i=0;i<=4096;i++) {
g_buf[i] = i;
}
std::cout << " test1 " << g_buf[4096];
}
void test2() {
int* buf = new int[4000];
for (int i=0;i<=4096;i++) {
buf[i] = i;
}
std::cout << " test2 " << buf[4096];
}
void test3() {
int* buf = (int*)malloc(sizeof(int)*4000);
for (int i=0;i<=4096;i++) {
buf[i] = i;
}
std::cout << " test3 " << buf[4096];
}
int main(int argc, char** argv) {
test1();
test2();
test3();
}
CSNpbmNsdWRlIDxpb3N0cmVhbT4KCSNpbmNsdWRlIDxtZW1vcnk+CgkjaW5jbHVkZSA8Y3N0ZGxpYj4KCglpbnQgZ19idWZbNDAwMF07CgoJdm9pZCB0ZXN0MSgpIHsKCQlmb3IgKGludCBpPTA7aTw9NDA5NjtpKyspIHsKCQkJZ19idWZbaV0gPSBpOwoJCX0KCQlzdGQ6OmNvdXQgPDwgIiB0ZXN0MSAiIDw8IGdfYnVmWzQwOTZdOwoJfQoKCXZvaWQgdGVzdDIoKSB7CgkJaW50KiBidWYgPSBuZXcgaW50WzQwMDBdOwoJCWZvciAoaW50IGk9MDtpPD00MDk2O2krKykgewoJCQlidWZbaV0gPSBpOwoJCX0KCQlzdGQ6OmNvdXQgPDwgIiB0ZXN0MiAiIDw8IGJ1Zls0MDk2XTsKCX0KCgl2b2lkIHRlc3QzKCkgewoJCWludCogYnVmID0gKGludCopbWFsbG9jKHNpemVvZihpbnQpKjQwMDApOwoJCWZvciAoaW50IGk9MDtpPD00MDk2O2krKykgewoJCQlidWZbaV0gPSBpOwoJCX0KCQlzdGQ6OmNvdXQgPDwgIiB0ZXN0MyAiIDw8IGJ1Zls0MDk2XTsKCX0KCglpbnQgbWFpbihpbnQgYXJnYywgY2hhcioqIGFyZ3YpIHsKCQl0ZXN0MSgpOwoJCXRlc3QyKCk7CgkJdGVzdDMoKTsKCX0KCgoK