Topic: Destructors and typedefs


Author: "Michael Kochetkov" <mkochetk@trustworks.commm>
Date: 2000/06/21
Raw View
I was unable to find out the issue in this NG and in the defects list. But
anyway I am sorry if it was discussed earlier.
Here is the code which is based upon the example from 12.4/12.
[Example:
struct B {
    virtual ~B() { }
};
struct D : B {
    ~D() { }
};

D D_object;
typedef B B_alias;
B* B_ptr = &D_object;

int main()
{
   D_object.B::~B();     // calls B's destructor
   B_ptr->~B();          // calls D's destructor
   B_ptr->~B_alias();    // calls D's destructor
   B_ptr->B_alias::~B(); // calls B's destructor
   B_ptr->B_alias::~B_alias(); // error, no B_alias in class B
}
end of example]

I aggree that B_ptr->B_alias::~B_alias() is ill-formed in this case. There
is no B_alias in B's scope indeed.

Let us consider the example from 3.4.3/5 now:
[Example:
struct A {
    ~A() {}
};

typedef A AB;

int
main()
{
   AB *p;
   p->AB::~AB(); // explicitly calls the destructor for A
}
end of example]

It is a contradiction, is not it? 12.4/12 says that p->AB::~AB() should
produce an error, while 3.4.3/5 names it as the explicit destructor's call.

Do I miss something or should it be considered as the defect report?

Thank you in advance,
with regards,
Michael Kochetkov.



---
[ 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://reality.sgi.com/austern_mti/std-c++/faq.html              ]






Author: wmm@fastdial.net
Date: 2000/06/22
Raw View
In article <394f9472@news.telekom.ru>,
  "Michael Kochetkov" <mkochetk@trustworks.commm> wrote:
> I was unable to find out the issue in this NG and in the defects
list. But
> anyway I am sorry if it was discussed earlier.
> Here is the code which is based upon the example from 12.4/12.
...
> Let us consider the example from 3.4.3/5 now:
> [Example:
> struct A {
>     ~A() {}
> };
>
> typedef A AB;
>
> int
> main()
> {
>    AB *p;
>    p->AB::~AB(); // explicitly calls the destructor for A
> }
> end of example]
>
> It is a contradiction, is not it? 12.4/12 says that p->AB::~AB()
should
> produce an error, while 3.4.3/5 names it as the explicit destructor's
call.
>
> Do I miss something or should it be considered as the defect report?

That looks like a genuine bug to me.  I'll add it to the
issues list.  Thanks for pointing it out.
--
William M. Miller, wmm@fastdial.net
OnDisplay, Inc. (www.ondisplay.com)


Sent via Deja.com http://www.deja.com/
Before you buy.

---
[ 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://reality.sgi.com/austern_mti/std-c++/faq.html              ]