public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/22364] New: Problems with friend function injection and destructor
@ 2005-07-08 11:18 cxl at ntllib dot org
2005-07-08 14:19 ` [Bug c++/22364] " bangerth at dealii dot org
0 siblings, 1 reply; 2+ messages in thread
From: cxl at ntllib dot org @ 2005-07-08 11:18 UTC (permalink / raw)
To: gcc-bugs
This code does not compile:
template <class T>
struct Feature {
friend void AssertFeature0(T *) {}
};
template <class T>
inline void AssertFeature(T *t = 0) { if(t) AssertFeature0(t); }
template <class T>
struct Test : Feature< Test<T> >
{
int i;
~Test() { AssertFeature<T>(); }
};
struct Foo : Feature<Foo> { int x; };
void foo()
{
Test< Test<Foo> > test;
}
----------------------
The problem seems to be in fact that ~Test destructor is instantiated BEFORE
friend is injected and only in the case that templates are nested. Moving
AssertFeature to other method (and instatiating) or reducing test-case to just
"Test<Foo> test;" makes code compile fine.
Comeau C++ testdrive compiles this code without problems.
--
Summary: Problems with friend function injection and destructor
Product: gcc
Version: 4.0.0
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: cxl at ntllib dot org
CC: gcc-bugs at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22364
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug c++/22364] Problems with friend function injection and destructor
2005-07-08 11:18 [Bug c++/22364] New: Problems with friend function injection and destructor cxl at ntllib dot org
@ 2005-07-08 14:19 ` bangerth at dealii dot org
0 siblings, 0 replies; 2+ messages in thread
From: bangerth at dealii dot org @ 2005-07-08 14:19 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From bangerth at dealii dot org 2005-07-08 14:19 -------
*** This bug has been marked as a duplicate of 22363 ***
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |DUPLICATE
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22364
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2005-07-08 14:19 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-07-08 11:18 [Bug c++/22364] New: Problems with friend function injection and destructor cxl at ntllib dot org
2005-07-08 14:19 ` [Bug c++/22364] " bangerth at dealii dot org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).