By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,191 Members | 757 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,191 IT Pros & Developers. It's quick & easy.

what is different?

P: n/a
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
Jul 22 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
On Sun, 7 Dec 2003 22:56:07 -0500, Yuming Ma <ma*******@yahoo.com>
wrote in comp.lang.c++:
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
Jul 22 '05 #2

P: n/a
Yuming Ma wrote:
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.

Jul 22 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.