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]

Re: c++/9602: [3.2/3.3/3.4 regression] Total confusion about template/friend/virtual/abstract


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


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