struct Big { char data[5000]; };
int main() {
switch (6) {
case 0: {
struct Big big;
big.data[0] = 0; // do something
return big.data[0];
} break;
case 1: {
struct Big big;
big.data[1] = 1;
return big.data[1];
} break;
case 2: {
struct Big big;
big.data[2] = 2;
big.data[2];
} break;
case 3: {
struct Big big;
big.data[3] = 3;
return big.data[3];
} break;
case 4: {
struct Big big;
big.data[4] = 4;
return big.data[4];
} break;
}
return 0;
}
I suppose 5000 bytes is enough for main(), but Visual studio 2022 reported: “Warning C6262 Function uses ‘25000’ bytes of stack. Consider moving some data to heap.”
Does that mean out-of-scope local variables’ memory is not reused?
New contributor
Erciyuanshagou is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.