Article View: de.comp.lang.c++
Article #61Bug in g++, but easy solution.
From: Harald Leszke
Date: Thu, 12 Nov 1992 14:57
Date: Thu, 12 Nov 1992 14:57
38 lines
1487 bytes
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.
Technical Details
Message-ID:
<1992Nov12.145736.2783@cs.tu-berlin.de>Path:
arc1-ca.pugleaf.net!sparky!uunet!paladin.american.edu!darwin.sura.net!Sirius.dfn.de!mailgzrz.TU-Berlin.DE!cs.tu-berlin.de!leszkeShow Full Headers
Complete Article Headers
Newsgroups: de.comp.lang.c++,gnu.bug.g++ Path: arc1-ca.pugleaf.net!sparky!uunet!paladin.american.edu!darwin.sura.net!Sirius.dfn.de!mailgzrz.TU-Berlin.DE!cs.tu-berlin.de!leszke From: leszke@opal.cs.tu-berlin.de (Harald Leszke) Subject: Bug in g++, but easy solution. Message-ID: <1992Nov12.145736.2783@cs.tu-berlin.de> Sender: news@cs.tu-berlin.de Organization: Techn. University of Berlin, Germany Date: Thu, 12 Nov 1992 14:57:36 GMT Lines: 38