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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T04:12:42+00:00 2026-05-26T04:12:42+00:00

Once again, thank you for the great help so far. The source code: int

  • 0

Once again, thank you for the great help so far.

The source code:

int main()
{ 
   int a = 20;
   int b = 10;
   int c;
   c = a + b;
return 0;   
}

Reading symbols from /home/jwxie/a.out...done.
(gdb) start
Temporary breakpoint 1 at 0x80483fa: file demoo.cpp, line 3.
Starting program: /home/jwxie/a.out 

Temporary breakpoint 1, main () at demoo.cpp:3
3      int a = 20;
(gdb) x/wx $ebp-8
0xbffff3a0: 0x08048420
(gdb) x/wx $ebp-4
0xbffff3a4: 0x00000000
(gdb) info locals
a = 0
b = 134513696
c = 3903476
(gdb) x/wx $ebp-8
0xbffff3a0: 0x08048420
(gdb) x/wx $ebp-12
0xbffff39c: 0x003b8ff4

-- Now execute int a = 20;
(gdb) stepi
4      int b = 10;

(gdb) x/wx $ebp-4
0xbffff3a4: 0x00000014

(gdb) info locals
a = 20
b = 134513696
c = 3903476

(1)
I noticed that the values of a, b and c prior to any of the assignment remain the same no matter how many times I restart the debug or reboot.

I even disabled optimization: g++ -g -O0 demo.cpp

Why is that?

(2)
Another strange thing is that, after each stepi, esp never changed, unlike in Visual Studio, we can observe the change of esp and ebp…
The log is can be found in here: info registers

What is the problem here?
Thank you very much.


EDIT
Yes. Thank you. Here is the disas

    (gdb) disas /m main
Dump of assembler code for function main():
2   { 
   0x080483f4 <+0>: push   %ebp
   0x080483f5 <+1>: mov    %esp,%ebp
   0x080483f7 <+3>: sub    $0x10,%esp

3      int a = 20;
   0x080483fa <+6>: movl   $0x14,-0x4(%ebp)

4      int b = 10;
   0x08048401 <+13>:    movl   $0xa,-0x8(%ebp)

5      int c;
6      c = a + b;
   0x08048408 <+20>:    mov    -0x8(%ebp),%eax
   0x0804840b <+23>:    mov    -0x4(%ebp),%edx
   0x0804840e <+26>:    lea    (%edx,%eax,1),%eax
   0x08048411 <+29>:    mov    %eax,-0xc(%ebp)

7   return 0;   
   0x08048414 <+32>:    mov    $0x0,%eax

8   }
   0x08048419 <+37>:    leave  
   0x0804841a <+38>:    ret    

End of assembler dump.
  • 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-26T04:12:42+00:00Added an answer on May 26, 2026 at 4:12 am

    There is no guarantee that variable values, before initialization, will always be the same. Some debuggers will initialize memory to fixed values, e.g. 0xDEADBEEF, some will clear to zero, others will not do anything and you get what was in memory.

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

Sidebar

Related Questions

Hello again great knowledge masters of stackoverflow, once again the small coder apprentice tabaluga
I am in need of database help once again. Yes Efficiency matters A LOT.
I think I've seen this done once, but I cannot find it again after
Once again one of those: Is there an easier built-in way of doing things
Once again a very beginner-ish question, but here I go: I would like to
Once again a question about the garbage collector in actionscript-3: If I have a
Once again I'm doing Java graphics (Graphics2D) but I noticed there is no Polygon.Double
Once again I find myself failing at some really simple task in C++. Sometimes
Once again I was in a design review, and encountered the claim that the
I need your expertise once again. I have a java class that searches a

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.