public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/51048] New: Class template inheritance doesn't work well with function-local types
@ 2011-11-09  6:42 Fetrovsky at gmail dot com
  2011-11-09 12:38 ` [Bug c++/51048] " daniel.kruegler at googlemail dot com
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: Fetrovsky at gmail dot com @ 2011-11-09  6:42 UTC (permalink / raw)
  To: gcc-bugs

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: unassigned@gcc.gnu.org
        ReportedBy: Fetrovsky@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.


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2015-10-12 13:17 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-11-09  6:42 [Bug c++/51048] New: Class template inheritance doesn't work well with function-local types Fetrovsky at gmail dot com
2011-11-09 12:38 ` [Bug c++/51048] " daniel.kruegler at googlemail dot com
2013-07-30 22:55 ` paolo.carlini at oracle dot com
2013-09-28 15:08 ` cameron314 at gmail dot com
2013-09-28 15:10 ` cameron314 at gmail dot com
2015-06-15 11:16 ` paolo.carlini at oracle dot com
2015-06-15 12:01 ` paolo.carlini at oracle dot com
2015-06-15 19:27 ` paolo at gcc dot gnu.org
2015-10-12 13:16 ` paolo at gcc dot gnu.org
2015-10-12 13:17 ` paolo.carlini at oracle dot com

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