From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17735 invoked by alias); 2 Mar 2011 16:06:25 -0000 Received: (qmail 17696 invoked by uid 22791); 2 Mar 2011 16:06:24 -0000 X-SWARE-Spam-Status: No, hits=-2.9 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 02 Mar 2011 16:06:21 +0000 From: "boostcpp at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/47957] New: Type mismatch when a class derived a same name with template parameter X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: boostcpp at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Date: Wed, 02 Mar 2011 16:06:00 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2011-03/txt/msg00195.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47957 Summary: Type mismatch when a class derived a same name with template parameter Product: gcc Version: 4.6.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned@gcc.gnu.org ReportedBy: boostcpp@gmail.com This bug report is for gcc 4.6(built in 2011/02/26) I tried other version(gcc 4.1). But it doesn't have this problem. struct Base { typedef int T ; } ; template < typename T > struct Derived : Base { T member ; // T is Base::T, its type is int. void f() {// for instantiation Derived< double > // type of T is double std::cout << "T= " << typeid(T).name() << std::endl ; T variable ; // type of variable is double std::cout << "variable= " << typeid(variable).name() << std::endl ; // type of member is int std::cout << "member= " << typeid(member).name() << std::endl; } }; int main() { Derived< double > d ; d.f() ; } Derived's base class is non-dependent name, so in the class scope Derived, name T is Base::T, not a template parameter name T. So for instantiation Derived, the name T in Derived class scope is Base::T. it's type is int. But in gcc 4.6, Although the type of Derived::member is int, the type of T become double in the member function body. It looks like gcc 4.6 treat name T as a template parameter T in member function body.