From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10138 invoked by alias); 13 Dec 2012 01:04:23 -0000 Received: (qmail 10103 invoked by uid 48); 13 Dec 2012 01:04:06 -0000 From: "tudorb at fb dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/55668] New: Incorrect lookup for template member of dependent template Date: Thu, 13 Dec 2012 01:04:00 -0000 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: tudorb at fb 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 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: 2012-12/txt/msg01275.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55668 Bug #: 55668 Summary: Incorrect lookup for template member of dependent template Classification: Unclassified Product: gcc Version: 4.7.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned@gcc.gnu.org ReportedBy: tudorb@fb.com The following correct program gives an error; it appears that "a.template foo<0>" looks up foo in global scope and fails because it believes that foo takes a class first template argument instead of an int. // The bug is not triggered if the template below is missing, // or if it is a class or function or global variable instead of // a template. template class foo; template struct A { template void foo(int val) { } }; template struct B { // The bug is not triggered if "bar" is named "foo" void bar() { a.template foo<0>(42); } // This has to depend on N; A<0> doesn't trigger the bug A a; }; The error I get: d.cpp: In member function `void B::bar()`: d.cpp:13:21: error: type/value mismatch at argument 1 in template parameter list for `template class foo` d.cpp:13:21: error: expected a type, got `0` Broken in 4.1.2, 4.6.2, 4.7.1 (the three versions I have access to). (The bug was minimized from actual code, in which the method in question was named "set" and collided with std::set, as we had "using std::set")