Thread View: gnu.g++.bug
2 messages
2 total messages
Started by Mike Thome
Mon, 16 Oct 1989 19:59
G++ 1.36 problem?
Author: Mike Thome
Date: Mon, 16 Oct 1989 19:59
Date: Mon, 16 Oct 1989 19:59
22 lines
1059 bytes
1059 bytes
Now that I've got g++ working here (thanks those who responded to my
earlier plea for help), I've got another problem...
The following code fragment (from InterViews):
class Resource {
public:
Resource () { refcount = 1; }
~Resource () { if (--refcount > 0) { this = 0; } }
void Reference () { ++refcount; }
int LastRef () { return refcount == 1; }
private:
unsigned refcount;
};
Generates the following error message:
foo.c: In method Resource::~Resource ():
foo.c:4: assignment of read-only parameter `$this'
As far as I can tell from Stroustrup, this appears to be a perfectly
valid use of THIS in a destructer. What's going on here?
-mik (mthome@bbn.com, mthome@thalamus.bu.edu)
Re: G++ 1.36 problem?
Author: Doug Schmidt
Date: Mon, 16 Oct 1989 22:20
Date: Mon, 16 Oct 1989 22:20
31 lines
1739 bytes
1739 bytes
In article <46991@bbn.COM>, mthome@bbn (Mike Thome) writes:
>Now that I've got g++ working here (thanks those who responded to my
>earlier plea for help), I've got another problem...
>The following code fragment (from InterViews):
> class Resource {
> public:
> Resource () { refcount = 1; }
> ~Resource () { if (--refcount > 0) { this = 0; } }
>
> void Reference () { ++refcount; }
> int LastRef () { return refcount == 1; }
> private:
> unsigned refcount;
> };
>
>Generates the following error message:
> foo.c: In method Resource::~Resource ():
> foo.c:4: assignment of read-only parameter `$this'
>
>As far as I can tell from Stroustrup, this appears to be a perfectly
>valid use of THIS in a destructer. What's going on here?
Assigning to this is an anachronism. However, you can make g++
accept this via the -fthis-is-variable option.
Doug
--
Master Swordsman speak of humility; | schmidt@ics.uci.edu (ARPA)
Philosophers speak of truth; | office: (714) 856-4034
Saints and wisemen speak of the Tao of no doubt;
The moon, sun, and sea speaks for itself. -- Hiroshi Hamada
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