in Education by
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). JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
Just because the initialization is lazy, the allocation isn't. The standard requires all static variables (including local variables) to be zero initialized before the start of program. And in fact, static means just that (in this case): the space for the variable is present for the entire lifetime of the program.

Related questions

0 votes
    static storage is decided at compilation time. However, consider the scenario where we have lot of lazy ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 4, 2022 in Education by JackTerrance
0 votes
    static storage is decided at compilation time. However, consider the scenario where we have lot of lazy ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 2, 2022 in Education by JackTerrance
0 votes
    So I've got some C code: #include #include /* putting one of the "char*"s here causes a segfault ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 19, 2022 in Education by JackTerrance
0 votes
    In my signal.h file I have added a signal handler like this: #define SIG_WPG ((__sighandler_t)3) and ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 13, 2022 in Education by JackTerrance
0 votes
    I have a class that logs on to a server and retrieves some data. The data is put in a NSMutableArray, ... [heleTeksten componentsSeparatedByString:@"\n"]; NSString *searchFor = @"...
asked Jan 16, 2022 in Education by JackTerrance
0 votes
    What are the common causes of the segmentation fault in C?...
asked Jan 22, 2021 in Technology by JackTerrance
0 votes
    What is the difference between Segmentation fault and Bus error?...
asked Jan 22, 2021 in Technology by JackTerrance
0 votes
    What is segmentation fault in C?...
asked Jan 22, 2021 in Technology by JackTerrance
0 votes
    Buffer-overflow attack can take place if a machine can execute a code that resides in the data/stack segment. (a ... Security questions and answers pdf, mcq on Cyber Security pdf,...
asked Nov 4, 2021 in Education by JackTerrance
0 votes
    App permissions can cause trouble as some apps may secretly access your memory card or contact data. (a) ... -for-Cyber Security:,Cyber Security-Jobs:,Cyber Security Applications...
asked Nov 1, 2021 in Education by JackTerrance
0 votes
    Write a program in 8086 to move hundred bytes of data from the offset address 3000H in the segment 4000H Select the correct answer from above options...
asked Dec 20, 2021 in Education by JackTerrance
0 votes
    I'm trying to embed python into a C application. For the moment, I am trying to get the following ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 21, 2022 in Education by JackTerrance
0 votes
    Clicking on enticing Ads can cause trouble. (a) True (b) False I have been asked this question during ... Need-for-Cyber Security:,Cyber Security-Jobs:,Cyber Security Applications...
asked Oct 31, 2021 in Education by JackTerrance
...