Nested functions deeper than level 2 corrupt stack
Status: Alpha
Brought to you by:
dvdfrdmn
Consider the following:
void f1(int a,int b) {
void f2(int c) {
void f3(int d) {
printf("a=%d, b=%d, c=%d, d=%d\n",a,b,c,d);
}
f3(4);
}
f2(3);
}
void main(string[] args) {
f1(1,2);
}
The output should be:
a=1, b=2
a=1, b=2, c=3
a=1, b=2, c=3, d=4
But I got the following:
a=1, b=2
a=1, b=2, c=3
a=-1869560995, b=1527563395, c=3, d=4
So, as it seems the stack is getting currupted when calling the third nested function.
My gdc-version:
gcc version 4.2.4 20080705 (prerelease gdc 0.25 20080312, using dmd 1.024) (Ubuntu 0.25-4.2.4-3.1)
uname -a:
Linux hrniels-desktop 2.6.31-20-generic #57-Ubuntu SMP Mon Feb 8 09:05:19 UTC 2010 i686 GNU/Linux