public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
* [Bug c++/31881] New: inherited members invisible within nested class within templated class @ 2007-05-09 16:19 ghood at psc dot edu 2007-05-09 16:22 ` [Bug c++/31881] " ghood at psc dot edu ` (2 more replies) 0 siblings, 3 replies; 4+ messages in thread From: ghood at psc dot edu @ 2007-05-09 16:19 UTC (permalink / raw) To: gcc-bugs [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #1: Type: text/plain, Size: 1272 bytes --] Here is the code (nest.cc) that exhibits the error: template<class X> class A { public: class B { public: int i; }; class C: public B { public: void f() { this->i; // OK i; // results in "error: i was not declared in this scope" // even though i should be inherited from B } }; }; This code generate an error when compiled with "g++ -v -save-temps -c nest.cc" on powerpc-linux-gnu using gcc 4.1.2, on i386-redhat-linux using gcc 4.1.0, and on x86_64-redhat-linux using gcc 3.4.5. This is somehow related to the classes being templated because removing the template<class X> line will eliminate the error. It compiles without problem on i386-redhat-linux using gcc 3.2.2, on x86_64-redhat-linux using PGI's pgCC 6.1.6, and on x86_64-redhat-linux using Intel's icc 9.1. -- Summary: inherited members invisible within nested class within templated class Product: gcc Version: 4.1.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: ghood at psc dot edu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31881 ^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/31881] inherited members invisible within nested class within templated class 2007-05-09 16:19 [Bug c++/31881] New: inherited members invisible within nested class within templated class ghood at psc dot edu @ 2007-05-09 16:22 ` ghood at psc dot edu 2007-05-09 16:23 ` pinskia at gcc dot gnu dot org 2007-05-09 18:05 ` ghood at psc dot edu 2 siblings, 0 replies; 4+ messages in thread From: ghood at psc dot edu @ 2007-05-09 16:22 UTC (permalink / raw) To: gcc-bugs ------- Comment #1 from ghood at psc dot edu 2007-05-09 17:22 ------- Created an attachment (id=13534) --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=13534&action=view) nest.ii -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31881 ^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/31881] inherited members invisible within nested class within templated class 2007-05-09 16:19 [Bug c++/31881] New: inherited members invisible within nested class within templated class ghood at psc dot edu 2007-05-09 16:22 ` [Bug c++/31881] " ghood at psc dot edu @ 2007-05-09 16:23 ` pinskia at gcc dot gnu dot org 2007-05-09 18:05 ` ghood at psc dot edu 2 siblings, 0 replies; 4+ messages in thread From: pinskia at gcc dot gnu dot org @ 2007-05-09 16:23 UTC (permalink / raw) To: gcc-bugs ------- Comment #2 from pinskia at gcc dot gnu dot org 2007-05-09 17:23 ------- I don't think this is a bug. class B is dependent so the inherited elements are not seen. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31881 ^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/31881] inherited members invisible within nested class within templated class 2007-05-09 16:19 [Bug c++/31881] New: inherited members invisible within nested class within templated class ghood at psc dot edu 2007-05-09 16:22 ` [Bug c++/31881] " ghood at psc dot edu 2007-05-09 16:23 ` pinskia at gcc dot gnu dot org @ 2007-05-09 18:05 ` ghood at psc dot edu 2 siblings, 0 replies; 4+ messages in thread From: ghood at psc dot edu @ 2007-05-09 18:05 UTC (permalink / raw) To: gcc-bugs ------- Comment #3 from ghood at psc dot edu 2007-05-09 19:04 ------- OK, I now understand the issue here. The fact that B and C were not explicitly templatized, and the other compilers accepted it, led me to think that it was valid code. In case anyone else is interested, there's an explanation at: http://womble.decadentplace.org.uk/c++/template-faq.html#base-lookup Thanks. -- ghood at psc dot edu changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |RESOLVED Resolution| |INVALID http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31881 ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2007-05-09 18:05 UTC | newest] Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2007-05-09 16:19 [Bug c++/31881] New: inherited members invisible within nested class within templated class ghood at psc dot edu 2007-05-09 16:22 ` [Bug c++/31881] " ghood at psc dot edu 2007-05-09 16:23 ` pinskia at gcc dot gnu dot org 2007-05-09 18:05 ` ghood at psc dot edu
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).