Skip to content

Instantly share code, notes, and snippets.

@7shi
Created October 9, 2011 12:01
Show Gist options
  • Save 7shi/1273594 to your computer and use it in GitHub Desktop.
Save 7shi/1273594 to your computer and use it in GitHub Desktop.
スタック消費テスト
#include <stdio.h>
#include <array>
#include <vector>
void test1() {
int a;
printf("test1.&a: %p\n", &a);
}
void test2() {
int _[4096];
_[0] = 0;
test1();
}
void test3() {
std::array<int, 4096> _;
_[0] = 0;
test1();
}
void test4() {
std::vector<int> _(4096);
_[0] = 0;
test1();
}
int main() {
int a;
printf("main.&a: %p\n", &a);
test1();
test2();
test3();
test4();
}
* Release build
main.&a: 0013FF78
test1.&a: 0013FF6C
test1.&a: 0013BF5C
test1.&a: 0013BF5C
test1.&a: 0013FF08
* Debug build
main.&a: 0013FF60
test1.&a: 0013FE80
test1.&a: 0013BDA0
test1.&a: 0013BDA0
test1.&a: 0013FD80
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment