Thread View: gnu.g++.bug
2 messages
2 total messages
Started by Dave Clemans APD x1292
Fri, 26 May 1989 22:01
G++ <-> C++ destructor difference
Author: 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
Re: G++ <-> C++ destructor difference
Author: Joe Sacco
Date: Sun, 28 May 1989 16:07
Date: Sun, 28 May 1989 16:07
11 lines
919 bytes
919 bytes
In article <1989May26.150134.24068@mntgfx.mentor.com>, dclemans@mntgfx.mentor.com (Dave Clemans @ APD x1292) observes :
There is a problem in the placement of the destructor definition in his
example. ......
There was a similar problem with unions. Both of these problems seem to
have vanished in 1.35.1-. I've installed the patches for 1.35.1- and
have found that both versions of Dave's example now compile and run.
JOE
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