From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Robert B. Lowrie" To: gcc-gnats@gcc.gnu.org Cc: furboo@cybermesa.com Subject: c++/3012: c++ bug Date: Thu, 31 May 2001 08:26:00 -0000 Message-id: <200105311522.f4VFMMJ28208@belle.lanl.gov> X-SW-Source: 2001-05/msg01059.html List-Id: >Number: 3012 >Category: c++ >Synopsis: templated member function fails within templated class >Confidential: no >Severity: critical >Priority: high >Responsible: unassigned >State: open >Class: rejects-legal >Submitter-Id: net >Arrival-Date: Thu May 31 08:26:01 PDT 2001 >Closed-Date: >Last-Modified: >Originator: Robert B. Lowrie >Release: 3.0 20010528 (prerelease) >Organization: >Environment: System: Linux belle 2.4.2-2 #1 Sun Apr 8 20:41:30 EDT 2001 i686 unknown Architecture: i686 host: i686-pc-linux-gnu build: i686-pc-linux-gnu target: i686-pc-linux-gnu configured with: ../gcc-20010528/configure --prefix=/usr/local/gcc-20010528 >Description: If a templated member function `foo' of even a non-templated class `A' is called within a templated class `B' with the syntax foo(), the compiler gives a syntax error. >How-To-Repeat: // Here is a code snippet that repeats the problem: #include // Defining B_IS_A_TEMPLATE makes class B a template and this code fails // to compile. If not defined (comment next line out), the code compiles // and runs successfully. #define B_IS_A_TEMPLATE class A { public: template void foo() const { T data; std::cout << data << std::endl; } }; #ifdef B_IS_A_TEMPLATE template #endif class B { public: void bar(const A& a) const { // when B is a template, compile fails on this line: a.foo(); } }; int main() { A a; #ifdef B_IS_A_TEMPLATE B b; #else B b; #endif b.bar(a); } >Fix: >Release-Note: >Audit-Trail: >Unformatted: