🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.g++.bug
Article #1160

g++ 2.3.2, exceptions, constructors and delete

#1160
From: (Pierre Arnaud)
Date: Tue, 22 Dec 1992 13:35
77 lines
2512 bytes
Hi !

I have just ported g++ 2.3.2 on my Smaky (a Swiss computer
using a 68020 and running a Swiss real time kernel). I enjoyed
the many improvement you added and very much appreciated that
some known bug have been fixed. But... I stumbled across some
new problems. I don't know if these are well known or if they
aren't bugs at all, but I have posted three problems below.


I tried to compile this small example :

---cut
class X {
  // ...
public:
  void operator delete (void*, long);
};
---cut

and I got an error saying that "operator delete cannot
be overloaded". Strange indeed, because Stroustrup says it
is possible (C++ prog lang, 2nd ed, section r.12.4, p.577)
or haven't I got it the right way ?


Well, I heard that the exceptions didn't work fine, but is
this to say that they don't work at all ? I tried following :

--cut
  try { } catch (...) { throw; }
--cut

and compiled it with the -fansi-exceptions flag, but all I
got was a strange error saying that "cannot convert a pointer
of type `ExceptionHandler' to a pointer of type `'". It is
rather explicit, isn't it ? (-:


Another problem, when calling a function with a class as a
parameter, I get some trouble :

---cut
class X {

public:
  X () { printf ("construct\n"); }
  ~X () { printf ("destroy\n"); }
};

void foo (X x) { printf ("foo\n"); }

int main ()
{
  foo (X ());
  return 0;
}
---cut

I expected to get the messages "construct", "foo" and "destroy",
but I get "destroy" twice. In fact, the destructor gets called
within `foo' and within `main'. Why ?

Could you please have a look at these small examples and give
me some feed-back ? I would be pleased if you could fix these
small problems. I am highly interested in the exception
mechanisms of g++ !


I wich you Marry Chrismas and a happy new year !!!

  Pierre ARNAUD


Pierre ARNAUD :: EPSITEC-system SA :: CH-1437 Suscevaz, SWITZERLAND
  arnaud@lamisun.epfl.ch :: Swiss Federal Institute of Technology
          "There is always one more bug." (Murphy's law)
Technical Details
Message-ID: <9212221135.AA06826@lamisun3.epfl.ch>
Path: arc1-ca.pugleaf.net!sparky!uunet!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!lamisun.epfl.ch!arnaud

Show Full Headers
Complete Article Headers
Newsgroups: gnu.g++.bug
Path: arc1-ca.pugleaf.net!sparky!uunet!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!lamisun.epfl.ch!arnaud
From: arnaud@lamisun.epfl.ch ((Pierre Arnaud))
Subject: g++ 2.3.2, exceptions, constructors and delete
Message-ID: <9212221135.AA06826@lamisun3.epfl.ch>
Sender: gnulists@ai.mit.edu
Organization: GNUs Not Usenet
Distribution: gnu
Date: Tue, 22 Dec 1992 13:35:47 GMT
Approved: bug-g++@prep.ai.mit.edu
Lines: 79