[Bug c++/17648] [3.3/3.4 Regression] template destructor was not called for inherited classes
giovannibajo at libero dot it
gcc-bugzilla@gcc.gnu.org
Thu Oct 28 16:33:00 GMT 2004
------- 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
More information about the Gcc-bugs
mailing list