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 6938117
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T12:27:05+00:00 2026-05-27T12:27:05+00:00

In my mind, always, definition means storage allocation. In the following code, int i

  • 0

In my mind, always, definition means storage allocation.

In the following code, int i allocates a 4-byte (typically) storage on program stack and bind it to i, and i = 3 assigns 3 to that storage. But because of goto, definition is bypassed which means there is no storage allocated for i.

I heard that local variables are allocated either at the entry of the function (f() in this case) where they reside, or at the point of definition.

But either way, how can i be used while it hasn’t been defined yet (no storage at all)? Where does the value three assigned to when executing i = 3?

void f()
{
    goto label;
    int i;

label:
    i = 3;
    cout << i << endl; //prints 3 successfully
}
  • 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-27T12:27:06+00:00Added an answer on May 27, 2026 at 12:27 pm

    Long story short; goto will result is a runtime jump, variable definition/declaration will result in storage allocation, compile time.

    The compiler will see and decide on how much storage to allocate for an int, it will also make so that this allocated storage will be set to 3 when “hitting” i = 3;.

    That memory location will be there even if there is a goto at the start of your function, before the declaration/definition, just as in your example.


    Very silly simile

    If I place a log on the ground and my friend runs (with his eyes closed) and jumps over it, the log will still be there – even if he hasn’t seen or felt it.

    It’s realistic to say that he could turn around (at a later time) and set it on fire, if he wanted to. His jump doesn’t make the log magically disappear.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I always had this question: When i dont mind the exact floating number Which
I'm writing a PHP application with testability in mind, so my classes always ask
This has always lingered in the back of my mind, so I figure I
Two things jump to mind: using a Gee.TreeSet, which is always sorted, or calling
I encountered the following macro definition when reading the globals.h in the Google V8
This has always been on my mind while programming, so I thought I'd spit
I always try to create my Applications with memory usage in mind, if you
I've always admired the original uTorrent program. It looked great, was less than 64kb,
This question came to mind after seeing this simple piece of code: if (!x%y)
I always had this silly doubt in mind but never had come up with

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.