🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: de.comp.lang.c++
1 messages
1 total messages Started by Harald Leszke Thu, 12 Nov 1992 14:57
Bug in g++, but easy solution.
#61
Author: Harald Leszke
Date: Thu, 12 Nov 1992 14:57
38 lines
1487 bytes
Hello!
I had an Problem using the gcc for C++ some days ago.
It seems to be a Bug, and I can descripe it exactly now.

I used a class s_list containing memory structures and functions 
returning s_list. 
For example:


s_list operator =(s_list);

No Problem to compile this, but at runtime there are is a Problem.

s_list t,f;
Program calls t=f;

and gets stackmemory for arguments, returnaddress, and result.
The funktion calculates the result, an objekt of the class s_list. 
This result lives in the stackmemory.
When the funktion = is ready, the result form stack is copyed from stack
to datamemory of t using memcpy. The destructor for res is called, 
(this is the Bug) and the memory controled by res is lost.

Solution: 
   
s_list  &operator =(s_list);
        ^
        Thisway, no desructor is called.

Bye
  Harald.


--
Harald Leszke,Goerzalle 131/305,D-1000 Berlin 45, Tel: +49 (0)30 8178570

Wer mit 18 noch kein Kommunist ist, hat kein Herz!
	Und wer mit 28 noch Kommunist ist, hat keinen Verstand.
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads