public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Classes, References and the Stack
@ 1998-01-20 14:54 Orn E. Hansen
  0 siblings, 0 replies; only message in thread
From: Orn E. Hansen @ 1998-01-20 14:54 UTC (permalink / raw)
  To: egcs

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~1998-01-20 14:54 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-01-20 14:54 Classes, References and the Stack Orn E. Hansen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).