[prev in list] [next in list] [prev in thread] [next in thread]
List: llvm-dev
Subject: [LLVMdev] operator overloading fails while debugging with gdb for i386
From: Mayur Pandey <mayurthebond () gmail ! com>
Date: 2012-11-29 7:22:06
Message-ID: CAAk8+L7POBYWaBHS7OWJmX6mxr50864_YTZEFQn_2ian7F0B_g () mail ! gmail ! com
[Download RAW message or body]
[Attachment #2 (multipart/alternative)]
For the given test:
class A1 {
int x;
int y;
public:
A1(int a, int b)
{
x=a;
y=b;
}
A1 operator+(const A1&);
};
A1 A1::operator+(const A1& second)
{
A1 sum(0,0);
sum.x = x + second.x;
sum.y = y + second.y;
return (sum);
}
int main (void)
{
A1 one(2,3);
A1 two(4,5);
return 0;
}
when the exectable of this code is debugged in gdb for i386, we dont get the
expected results.
when we break at return 0; and give the command: print one + two, the result
should be $1 = {x = 6, y = 8}, but the result obtained is $1 = {x = 2, y = 3}.
This is related to debug information generated, as normally the overloading is
occuring.
eg: A1 three = one + two results {x = 6, y = 8}.
On checking the assembly, a suspicious entry is found which may be related for
the failure:
#DEBUG_VALUE: operator+:this <- undef
#DEBUG_VALUE: operator+:second <- undef
--
Thanx & Regards
*Mayur Pandey *
[Attachment #5 (text/html)]
<pre class="bz_comment_text" id="comment_text_0" \
style="font-size:small;font-family:monospace;white-space:pre-wrap;width:50em;color:rgb \
(0,0,0);font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal \
;line-height:normal;text-align:start;text-indent:0px;text-transform:none;word-spacing:0px;background-color:rgb(255,255,255)">
For the given test:
class A1 {
int x;
int y;
public:
A1(int a, int b)
{
x=a;
y=b;
}
A1 operator+(const A1&);
};
A1 A1::operator+(const A1& second)
{
A1 sum(0,0);
sum.x = x + second.x;
sum.y = y + second.y;
return (sum);
}
int main (void)
{
A1 one(2,3);
A1 two(4,5);
return 0;
}
when the exectable of this code is debugged in gdb for i386, we dont get the
expected results.
when we break at return 0; and give the command: print one + two, the result
should be $1 = {x = 6, y = 8}, but the result obtained is $1 = {x = 2, y = 3}.
This is related to debug information generated, as normally the overloading is
occuring.
eg: A1 three = one + two results {x = 6, y = 8}.
On checking the assembly, a suspicious entry is found which may be related for
the failure:
#DEBUG_VALUE: operator+:this <- undef
#DEBUG_VALUE: operator+:second <- undef</pre><br clear="all"><br>-- \
<br><div>Thanx & Regards <br></div> <div><b>Mayur Pandey \
</b><br></div><br><div><font color="#3333ff"> <br></font></div> <div> </div>
<div> </div><br>
_______________________________________________
LLVM Developers mailing list
LLVMdev@cs.uiuc.edu http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic