From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23620 invoked by alias); 12 Apr 2013 23:35:20 -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 Received: (qmail 23585 invoked by uid 48); 12 Apr 2013 23:35:16 -0000 From: "zeratul976 at hotmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/56943] New: Incorrect two-phase name lookup for operators Date: Fri, 12 Apr 2013 23:35: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: zeratul976 at hotmail 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 X-SW-Source: 2013-04/txt/msg01325.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56943 Bug #: 56943 Summary: Incorrect two-phase name lookup for operators Classification: Unclassified Product: gcc Version: 4.9.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned@gcc.gnu.org ReportedBy: zeratul976@hotmail.com When the following code is run: #include namespace N { struct A { int operator+(const void*) { return 42; } }; } namespace M { struct B { }; } template int add(T t, U u) { return t + u; } int operator+(N::A, M::B*) { return 5; } int main(int argc, char** argv) { N::A a; M::B b; std::cout << add(a, &b) << "\n"; } the output is "5". I believe the correct output wouldbe "42", because when looking up operator+ in the expression "t + u", the operator+(N::A, M::B*) overload is found neither by unqualified lookup at the point of definition (since it is not declared yet at the point of definition), nor by argument-dependent lookup at the point of instantiation (since it is not in the namespace of either of its arguments). Clang outputs "42" for this example, as expected.