For following code, the last output (which is max stack depth is keeping changing):
#include <stdio.h>
#include <windows.h>
int depth=0;
void func(){
int x=depth;
printf("%d\n",depth++);
func();
printf("%d\n",x);
}
int main(){
func();
return 0;
}
// compiled by cl /F 1 test.c
The first time is 3717, the second is 3700, the third is 3695.
I thought for constant stack size, max stack depth should be constant. but why is it changing?