Article View: gnu.g++.bug
Article #1721BUG(s) in G++ 1.34.0 - missing errors (again)
From: Ron Guilmette
Date: Fri, 10 Mar 1989 22:31
Date: Fri, 10 Mar 1989 22:31
74 lines
2874 bytes
2874 bytes
This bug report (for G++ 1.34.0/Sun3) is very much like my previous one about
private constructors, except this one is about private destructors.
In either case, the programmer should be allowed to make certain operations
of a given class (such as assignment, construction, and destruction) illegal
outside of the class just by declaring these operations within the private
part of the class declaration.
Unfortunately, g++ doesn't (currently) let you control the visibility of
constructors or destructors this way. These operations remain accessable
anywhere regardless of their public or private status.
The following code demonstrates this. I believe that all of the lines
marked with // ERROR should have errors messages issued for them because
these are the places where base::~base() gets (implicitly) called.
Following the code is a compilation log.
Cut here
------------------------------------------------------------------------------
/*
Description - check that if a destructor is needed (e.g. at the point
where an object is destroyed) and that if there is a destructor
for the class of the object, but it is private, a reasonable
error message is issued.
Cases: objects which are: (1) static (2) auto (3) heap.
Cases: objects of (1) a type which has a private default
constructor, and (2) objects of a type derived from a type
which has a private default constructor.
*/
class base
{
~base();
friend class friendly;
};
static base static_base_object_1; // ERROR
base static_base_object_2; // ERROR
void f1 ()
{
base local_base_object;
base *base_ptr = new base;
return; // ERROR, ERROR
}
class derived : base
{
public:
~derived();
};
static derived static_derived_object_1; // ERROR
derived static_derived_object_2; // ERROR
void f2()
{
derived local_derived_object;
derived *derived_ptr = new derived;
return; // ERROR, ERROR
}
----------------------------------------------------------------------------------
g++ -S -v x03.cc
g++ version 1.34.0.0
/usr/local/src/lib/1.34.0.0/sun3/gcc-cpp -+ -v -undef -D__GNU__ -D__GNUG__ -Dmc68000 -Dsun -Dunix -D__mc68000__ -D__sun__ -D__unix__ -D__HAVE_68881__ -Dmc68020 x03.cc /tmp/cca07729.cpp
GNU CPP version 1.34.0.0
/usr/local/src/lib/1.34.0.0/sun3/gcc-c++ /tmp/cca07729.cpp -quiet -dumpbase x03.cc -noreg -version -o x03.s
GNU C++ version 1.34.0.0 (68k, MIT syntax) compiled by GNU C version 1.33.
Technical Details
Message-ID:
<8903102231.AA07752@riunite.aca.mcc.com>Path:
arc1-ca.pugleaf.net!utzoo!telly!attcan!uunet!tut.cis.ohio-state.edu!MCC.COM!rfgShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!telly!attcan!uunet!tut.cis.ohio-state.edu!MCC.COM!rfg From: rfg@MCC.COM (Ron Guilmette) Newsgroups: gnu.g++.bug Subject: BUG(s) in G++ 1.34.0 - missing errors (again) Message-ID: <8903102231.AA07752@riunite.aca.mcc.com> Date: 10 Mar 89 22:31:58 GMT Sender: daemon@tut.cis.ohio-state.edu Distribution: gnu Organization: GNUs Not Usenet Lines: 74