static
storage is decided at compilation time. However, consider the scenario where we have lot of lazy initialization in functions:
void foo ()
{
static int a[1000];
}
I am not discussing the coding practice here, but the technical aspect. As many such other functions like foo()
are executed, those many static
variables will be introduced on data segment.
Will compiler take the lazy initialization also in the account while allocating space for data segment. If 'No' then, will it cause segmentation fault at runtime while the code is executing ? (more likely to happen when lot of static
data inside template
methods).