This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/17648] [3.3/3.4 Regression] template destructor was not called for inherited classes
- From: "giovannibajo at libero dot it" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 28 Oct 2004 16:32:59 -0000
- Subject: [Bug c++/17648] [3.3/3.4 Regression] template destructor was not called for inherited classes
- References: <20040924081036.17648.hs@profiforms.de>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Additional Comments From giovannibajo at libero dot it 2004-10-28 16:32 -------
Volker, thanks for the reduction. The bug is hideous, look at this:
----------------------------
class A;
template <int> struct B
{
A* a;
~B() { delete a; }
};
struct A {
B<0> b;
};
----------------------------
When B's destructor is instantiated, A must be a complete type, otherwise this
invokes undefined behaviour.
Now, B's destructor is instantiated when A's destructor is instantiated
(because it implicitally calls it), and at that point A is probably complete
(because its definition is already finished). At least, I think so.
This requires some legal help: is it true that B's destructor cannot be
instantiated before its first use, which is in the implicit A's destructor? Is
it true that, by the time that A's destructor is synthesized, A is a complete
type?
Either we have a codegen bug, or we are missing the warning (and probably
missing it also from 3.4 and mainline, even if we *happen* to generate the
correct code).
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17648