c++/9602: [3.2/3.3/3.4 regression] Total confusion about template/friend/virtual/abstract
bangerth@dealii.org
bangerth@dealii.org
Fri Feb 7 15:55:00 GMT 2003
Old Synopsis: falsely concludes that function defined within class body is virtual and abstract, therefore compiler fails to allow class instantiation with pure virtual function error.
New Synopsis: [3.2/3.3/3.4 regression] Total confusion about template/friend/virtual/abstract
State-Changed-From-To: feedback->analyzed
State-Changed-By: bangerth
State-Changed-When: Fri Feb 7 15:55:05 2003
State-Changed-Why:
Confirmed. This is a smaller testcase:
---------------------------
template <typename T> struct X {
void foo (X);
friend void bar () {}
};
template <typename T>
void X<T>::foo (X x) {}
template struct X<int>;
-----------------------------
There seems to be profound confusion within the compiler
about something, since it says
tmp/g> /home/bangerth/bin/gcc-3.2/bin/gcc -c x.cc
x.cc:7: cannot declare parameter `x' to be of type `X<T>'
x.cc:7: because the following virtual functions are abstract:
x.cc:3: void bar()
This is, of course, entirely bogus.
It worked with 3.0, but is broken with present 3.2.2, 3.3
and 3.4 branches, so it's a regression. The testcase is
so simple that I can't believe that this is something
that hasn't come up yet. Hopefully it's simple to fix.
From playing around, it seems to have to do with the fact
that the friend function is not only declared, but also
defined inside the class; it is instantiated at the place
of first use, which is where the error is displayed.
W.
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=9602
More information about the Gcc-bugs
mailing list