Consider the following C function.
Does opening the braces to create a local scope make compilers create a record on the stack to mantain the variables declared in the scope ?
void function()
{
int q,r;
...
{
int i = 0;
int j = 3;
q = j + 1;
}
...
}
If so , do compilers act the same with while blocks?
example:
void function()
{
int q,r;
...
while(conditions)
{
int i = 0;
int j = 3;
q = j + 1;
}
...
}
The arrangement of the stack is not specified by the C standard.
Curly braces (
{}) introduce a new scope, so in principle, yes, this could create a new frame on the stack. But the compiler may choose to optimise this overhead away.