http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51048

             Bug #: 51048
           Summary: Class template inheritance doesn't work well with
                    function-local types
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassig...@gcc.gnu.org
        ReportedBy: fetrov...@gmail.com


#include <vector>

template<typename X>
struct A { 
     X x;

     virtual X const& Push(X const& x) = 0;

     template<typename Y>
     X const& Push(Y const& y) {
          for (std::size_t i = 0; i < y.size(); ++i)
               Push(y[i]);
     }   
};

template<typename X>
struct B: A<X> {
     using A<X>::Push;
     virtual X const& Push(X const& x) { return A<X>::x = x; }
};

int F() {
     enum S { x, y };
     return B<S>().Push(std::vector<S>(3, x));
}

int main() {
     return F();
}


I get the following:
prog.cpp:7:23: error: 'const X& A<X>::Push(const X&) [with X = F()::S]',
declared using local type 'const F()::S', is used but never defined

If I take S out of F() and define it in the global namespace, it works fine.

Reply via email to