Open llvmbot opened 11 years ago
Still a problem for 32-bit.
In the above case, we see that the operator+ function's return value is returned in register edx. But gdb expects the return value in eax.
http://stackoverflow.com/questions/267674/inspect-the-return-value-of-a-function-in-gdb
so if we add the assembly instruction: movl %edx, %eax just before .loc 1 22 2 instruction in the assembly file and then compile with clang++ and run the executable, we get the desired results in gdb.
So probably this could be the reason. If this is it we might need to add another machine instruction. Just needs to be verified properly.
it was compiled using -O0.
Was this compiled with -O0 or some optimization?
Eric - this was the bug I was mentioning a few days ago.
I haven't looked into/tried to reproduce it yet, but figured one of us will get to it sooner or later
Extended Description
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: