Classes, References and the Stack
Orn E. Hansen
oe.hansen@oehansen.pp.se
Tue Jan 20 14:54:00 GMT 1998
Hi,
I've been using the egcs for a while, and I seem to be experiencing a
small problem, which maybe related to my own ignorance... yet, it's seems a
little strange.
----
class Symbol {
private:
<something>
public:
Symbol();
~Symbol();
Symbol& operator = (Symbol v);
};
Symbol& Symbol::operator = (Symbol v)
{
blah
}
.
.
.
Symbol get_some_symbol()
{
...
return symbol;
}
Symbol some_c_function()
{
Symbol b;
Symbol x;
x = b;
x = get_some_symbol();
return x;
}
-----
Ok, from the above, if I do 'b = x' where x and b are variables of class
Symbol, the assignment is ok. If I however, assign x from the function
'get_some_symbol' that returns a value of class symbol, it breaks inside the
assignment function for class Symbol. The reason is, that the class passed to
it, is non-existant and thus causes a SIGSEGV????
Of course, I may have missed something here, but this doesn't sound right.
But it appears, that the value returned by the function returning value of
class Symbol is put onto the stack (or it's address or whatever), but the stack
values appear overwritten when it reaches the assignment function. Is this a
known limitation?
----------------------------------------------------------------------------
Orn Einar Hansen oe.hansen@oehansen.pp.se
oehansen@daimi.aau.dk
voice+fax; +46 035 217194
More information about the Gcc
mailing list