Experimenting with gcc (4.8.3, 14.2.1) shows that the
stack layout depends on -O.
int fff(int yyy, int xxx)
{
int ab = yyy + xxx;
{
int bb;
printf("%p\n", &bb);
}
{
int bc;
printf("%p\n", &bc);
}
printf("%p\n", &ab);
return 0;
}
scott@slp53.sl.home (Scott Lurndal) writes:[...]
int fff(int yyy, int xxx)
{
int ab = yyy + xxx;
{
int bb;
printf("%p\n", &bb);
}
{
int bc;
printf("%p\n", &bc);
}
printf("%p\n", &ab);
return 0;
}
This function has undefined behavior.
| Sysop: | Jacob Catayoc |
|---|---|
| Location: | Pasay City, Metro Manila, Philippines |
| Users: | 4 |
| Nodes: | 4 (0 / 4) |
| Uptime: | 494928:19:17 |
| Calls: | 162 |
| Files: | 568 |
| D/L today: |
14 files (349K bytes) |
| Messages: | 74,957 |