This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/17648] [3.3/3.4 Regression] template destructor was not called for inherited classes


------- 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]