x86 - Can static storage (mostly data segment) cause segmentation fault? -



x86 - Can static storage (mostly data segment) cause segmentation fault? -

static storage decided @ compilation time. however, consider scenario have lot of lazy initialization in functions:

void foo () { static int a[1000]; }

i not discussing coding practice here, technical aspect. many such other functions like foo() executed, many static variables introduced on info segment.

will compiler take lazy initialization in business relationship while allocating space info segment. if 'no' then, cause segmentation fault @ runtime while code executing ? (more happen when lot of static info within template methods).

just because initialization lazy, allocation isn't. standard requires static variables (including local variables) 0 initialized before start of program. , in fact, static means (in case): space variable nowadays entire lifetime of program.

x86 segmentation-fault lazy-initialization data-segment

Comments

Popular posts from this blog

iphone - Dismissing a UIAlertView -

intellij idea - Update external libraries with intelij and java -

javascript - send data from a new window to previous window in php -