- 论坛徽章:
- 1
|
- #include <iostream>
- using namespace std;
- int main()
- {
- char s[100];
- int n[100];
- double d[100];
- sprintf(s, "%p", s);
- cout << s << endl;
- sprintf(s, "%p", n);
- cout << s << endl;
- sprintf(s, "%p", d);
- cout << s << endl;
- {
- char c;
- sprintf(s, "%p", &c);
- cout << s << endl;
- }
- }
复制代码
在AIX 5上用xlC_r编译(g++类似)
2ff22100
2ff22168
2ff222f8
2ff22618
在HP-UX上用aCC编译(g++类似)
77a70a10
77a70a74
77a70c08
77a70f28
在LINUX上
0xbfffe780
0xbfffe5f0
0xbfffe2d0
0xbfffe2cf
可以看出在AIX和HP上都是先把局部变量的空间先算出来,然后从低到高分配
之前说的溢出是因为用的visibroker线程有栈空间限制(只有64K?)分配了过多的局部变量的原因,而与地址增长无关 |
|