Article View: gnu.g++.bug
Article #2046G++ <-> C++ destructor difference
From: Dave Clemans APD x1292
Date: Fri, 26 May 1989 22:01
Date: Fri, 26 May 1989 22:01
93 lines
2388 bytes
2388 bytes
(This refers to version 1.35.0+ of G++)
The following example compiles fine under C++:
class xyz
{
int a1;
int b2;
int c3;
int d4;
public:
xyz()
{
a1 = 1;
b2 = 2;
c3 = 3;
d4 = 4;
}
~xyz()
{
}
int a() { return a1; }
int b() { return b2; }
int c() { return c3; }
int d() { return d4; }
};
xyz testing;
xyz testing2;
void main()
{
xyz onstack;
int i;
i = testing2.c() + testing.a() + onstack.b();
}
If I try to compile it under g++, I get...
[262]$ g++ tt.c
In method void xyz::~xyz ():
tt.c:19: parse error at end of input
tt.c:32: parse error before `{'
tt.c:32: warning: Old style parameter specification frowned upon
tt.c:19: parm types given both in parmlist and separately
tt.c:36: `testing' was not declared (first use this function)
tt.c:36: (Each undeclared identifier is reported only once
tt.c:36: for each function it appears in.)
But if the xyz destructor has its implementation moved out of the class
definition, g++ handles it fine. I.e.
class xyz
{
int a1;
int b2;
int c3;
int d4;
public:
xyz()
{
a1 = 1;
b2 = 2;
c3 = 3;
d4 = 4;
}
~xyz();
int a() { return a1; }
int b() { return b2; }
int c() { return c3; }
int d() { return d4; }
};
xyz::~xyz() { }
xyz testing;
xyz testing2;
void main()
{
xyz onstack;
int i;
i = testing2.c() + testing.a() + onstack.b();
}
dgc
Technical Details
Message-ID:
<1989May26.150134.24068@mntgfx.mentor.com>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!ucsd!ucbvax!tut.cis.ohio-state.edu!cs.utexas.edu!uunet!zephyr!tektronix!psueea!qiclab!mntgfx!dclemansShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!ucsd!ucbvax!tut.cis.ohio-state.edu!cs.utexas.edu!uunet!zephyr!tektronix!psueea!qiclab!mntgfx!dclemans From: dclemans@mntgfx.mentor.com (Dave Clemans @ APD x1292) Newsgroups: gnu.g++.bug Subject: G++ <-> C++ destructor difference Message-ID: <1989May26.150134.24068@mntgfx.mentor.com> Date: 26 May 89 22:01:33 GMT Organization: Mentor Graphics Corporation, Beaverton Oregon Lines: 93