Topic: Must explicit destructors always use a member access operator?


Author: "Andrea Ferro" <AndreaF@UrkaDVD.it>
Date: Thu, 22 Feb 2001 20:04:29 GMT
Raw View
"scott douglass" <sdouglass@arm.com> wrote in message
news:97089i$rok$1@cam-news1.cambridge.arm.com...
> In 12.4 [class.dtor] there is the following note:
>
> [Note: an explicit destructor call must always be written using a member
access
> operator
> (5.2.5); [...] ]
>
> I don't think that's true because the rest of the standard imposes no such
> restriction.  (But I wish it did.)  For example, I think the following is
legal
> (if ill-advised) :
>
> struct T {
>     void die();
>     ~T();
> };
>
> void T::die() {
>     T::~T();
> }
>
> Unless someone shows me what I've missed that makes the note correct I'll
submit
> a Defect Report.

I think it has to do with the fact that you should not be allowed to tamper with
the construction and destruction sequences.

Figure T::die called on a D istance with:

struct B {
    virtual ~B();
};

struct T: public B {
    void die();
    virtual ~T();
};

struct D: public T {
    virtual ~D();
};

void T::die() {
    T::~T();
}

Andrea Ferro

---------
Brainbench C++ Master. Scored higher than 97% of previous takers
Scores: Overall 4.46, Conceptual 5.0, Problem-Solving 5.0
More info http://www.brainbench.com/transcript.jsp?pid=2522556



---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html                ]
[ Note that the FAQ URL has changed!  Please update your bookmarks.     ]





Author: wmm@fastdial.net
Date: Thu, 22 Feb 2001 21:11:04 GMT
Raw View
In article <971kf4$6hm$1@serv1.iunet.it>, Andrea Ferro <AndreaF@UrkaDVD.it>
writes:
>"scott douglass" <sdouglass@arm.com> wrote in message
>news:97089i$rok$1@cam-news1.cambridge.arm.com...
>> In 12.4 [class.dtor] there is the following note:
>>
>> [Note: an explicit destructor call must always be written using a member
>access
>> operator
>> (5.2.5); [...] ]
>>
>> I don't think that's true because the rest of the standard imposes no such
>> restriction.  (But I wish it did.)  For example, I think the following is
>legal
>> (if ill-advised) :
>>
>> struct T {
>>     void die();
>>     ~T();
>> };
>>
>> void T::die() {
>>     T::~T();
>> }
>>
>> Unless someone shows me what I've missed that makes the note correct I'll
>submit
>> a Defect Report.
>
>I think it has to do with the fact that you should not be allowed to tamper
with
>the construction and destruction sequences.

No, it's only because of the syntactic ambiguity of a bare ~T().  That
could be interpreted as either a call to the destructor T::~T() or as
the unary "~" operator applied to an explicit temporary of type T.  The
standard resolves the ambiguity in favor of the latter interpretation.
(See 5.3.1p9.)

The original poster is correct: the note in 12.4p12 is imprecise at
best.  The ambiguity described in 5.3.1p9 and in view in this note is
not present for a qualified-id; the text should presumably read
something like "written using a member access operator (5.2.5) or a
qualfied-id."

There's no need to submit a formal Defect Report; I'll add it to the
core issues list directly.

-- William M. Miller



 -----  Posted via NewsOne.Net: Free (anonymous) Usenet News via the Web  -----
  http://newsone.net/ -- Free reading and anonymous posting to 60,000+ groups
   NewsOne.Net prohibits users from posting spam.  If this or other posts
made through NewsOne.Net violate posting guidelines, email abuse@newsone.net

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html                ]
[ Note that the FAQ URL has changed!  Please update your bookmarks.     ]





Author: scott douglass <sdouglass@arm.com>
Date: Wed, 21 Feb 2001 19:51:19 GMT
Raw View
In 12.4 [class.dtor] there is the following note:

[Note: an explicit destructor call must always be written using a member access
operator
(5.2.5); [...] ]

I don't think that's true because the rest of the standard imposes no such
restriction.  (But I wish it did.)  For example, I think the following is legal
(if ill-advised) :

struct T {
    void die();
    ~T();
};

void T::die() {
    T::~T();
}

Unless someone shows me what I've missed that makes the note correct I'll submit
a Defect Report.

There are two ways this could be fixed:  (a) remove that bit of the note or, my
preference, (b) exclude destructors from acquiring the implict '(*this).' in
9.3.1 [class.mfct.nonstatic].

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html                ]
[ Note that the FAQ URL has changed!  Please update your bookmarks.     ]