Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7009465
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T21:51:56+00:00 2026-05-27T21:51:56+00:00

All the initialized global/static variables will go to initialized data section . All the

  • 0

All the initialized global/static variables will go to initialized data section.
All the uninitialized global/static variables will go to uninitialed data section(BSS). The variables in BSS will get a value 0 during program load time.

If a global variable is explicitly initialized to zero (int myglobal = 0), where that variable will be stored?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T21:51:57+00:00Added an answer on May 27, 2026 at 9:51 pm

    Compiler is free to put such variable into bss as well as into data. For example, GCC has a special option controlling such behavior:

    -fno-zero-initialized-in-bss

    If the target supports a BSS section, GCC by default puts variables that are initialized to zero into BSS. This
    can save space in the resulting code. This option turns off this
    behavior because some programs explicitly rely on variables going to
    the data section. E.g., so that the resulting executable can find the
    beginning of that section and/or make assumptions based on that.

    The default is -fzero-initialized-in-bss.

    Tried with the following example (test.c file):

    int put_me_somewhere = 0;
    
    int main(int argc, char* argv[]) { return 0; }
    

    Compiling with no options (implicitly -fzero-initialized-in-bss):

    $ touch test.c && make test && objdump -x test | grep put_me_somewhere
    cc     test.c   -o test
    0000000000601028 g     O .bss   0000000000000004              put_me_somewhere
    

    Compiling with -fno-zero-initialized-in-bss option:

    $ touch test.c && make test CFLAGS=-fno-zero-initialized-in-bss && objdump -x test | grep put_me_somewhere
    cc -fno-zero-initialized-in-bss    test.c   -o test
    0000000000601018 g     O .data  0000000000000004              put_me_somewhere
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Why global and static variables are initialized to their default values? What
In an C program, I need to re-initialize all global variables as they where
We say that global variables and static variables are always initialized to 0. Then
My understanding about static variables declared inside a function is: If no initial value
First of all, I know global variables are evil :) However, there is legit
I'm exploiting the behavior of the constructors of C++ global variables to run code
If I understand correctly, the .bss section in ELF files is used to allocate
If I have two static variables in different compilation units, then their initialization order
I have one static variable declared inside a function, which is not initialized to
I'm used to thinking of all initialization of globals/static-class-members as happening before the first

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.