what is different?

Y

Yuming Ma

all,

// different of x and y

int main()
{
int i=1;
int &r=i;
int x = r;
int y;
y = r + 1;
}

compiled using g++ version 3.1 with "-g" option, trace the code through
gdb and used "info locals", strangely that "x" is not in the context while
"y" is. "print x" showed "No symbol "x" in the current context".

then what is the difference between "x" and "y" here?

thanks
 
J

Jack Klein

all,

// different of x and y

int main()
{
int i=1;
int &r=i;
int x = r;
int y;
y = r + 1;
}

compiled using g++ version 3.1 with "-g" option, trace the code through
gdb and used "info locals", strangely that "x" is not in the context while
"y" is. "print x" showed "No symbol "x" in the current context".

then what is the difference between "x" and "y" here?

thanks

There is no difference in x and y here, in that they are both signed
ints with automatic storage duration. If you have an issue or a
question about gdb, ask in one of the gnu.gcc.* groups. Debuggers are
off-topic here.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++ ftp://snurse-l.org/pub/acllc-c++/faq
 
R

Rolf Magnus

Yuming said:
all,

// different of x and y

int main()
{
int i=1;
int &r=i;
int x = r;
int y;
y = r + 1;
}

compiled using g++ version 3.1 with "-g" option, trace the code
through gdb and used "info locals", strangely that "x" is not in the
context while "y" is. "print x" showed "No symbol "x" in the current
context".

then what is the difference between "x" and "y" here?

Might be a compiler optimization. The compiler could e.g. determine that
nothing is done with x after it's created, so it might be optimized
away.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,777
Messages
2,569,604
Members
45,222
Latest member
patricajohnson51

Latest Threads

Top