problems viewing return values

Calvin Spealman calvin@ironfroggy.com
Fri Jan 31 18:41:00 GMT 2003


I'm having some trouble with viewing the return values of a member 
function in gdb. I've included a test case that demonstrates my 
problems. If you break after the Foo objects are created and step into 
the baz() function you will notice that if you try to print the x and y 
members they will be correct, but if you print the result of get(), it 
will be incorrect.

Also, I sometimes get an error from gdb saying "Function return value 
unknown.", but I don't know what that means exactly or what would cause it.

struct Bar {
         int x;
         int y;
         Bar(int a, int b) { x = a; y = b; }
};

struct Foo {
         int x;
         int y;
         Foo(int a, int b) { x = a; y = b; }
         Bar get();
         void baz() { }
};

Bar Foo::get() { Bar target(x, y); return target; }

int main()
{
         Foo *f = new Foo(1, 2);
         Foo *g = new Foo(3, 4);
         Foo h(5, 6);
         f->baz();
         g->baz();
         h.baz();

         delete f;
         delete g;

}



More information about the Gdb mailing list