From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27937 invoked by alias); 5 Jun 2012 11:14:17 -0000 Received: (qmail 27916 invoked by uid 22791); 5 Jun 2012 11:14:15 -0000 X-SWARE-Spam-Status: No, hits=-4.3 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00,KHOP_THREADED 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; Tue, 05 Jun 2012 11:14:02 +0000 From: "keean@fry-it.com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/53573] template type dependent name resolution broken Date: Tue, 05 Jun 2012 11:14:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: keean@fry-it.com X-Bugzilla-Status: RESOLVED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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-06/txt/msg00238.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D53573 --- Comment #12 from Keean Schupke 2012-06-05 11:14:00 U= TC --- (In reply to comment #10) although -fpermissive allows the code to compile (in some circumstances) it does not in all, and it also produces incorrect output, for example: #include char g(char x) { return x - 1; } template T f(T t) { return g(t); } double g(double x) { return x; } main() { double x(f(1.0L)); std::cout << x << "\n"; } will output "0" instead of "1" choosing the wrong overloaded function. In t= he case below: #include char g(char x) { return x - 1; } int g(int x) { return x + 1; } template T f(T t) { return g(t); } double g(double x) { return x; } main() { double x(f(1.0L)); std::cout << x << "\n"; } compilation still fails with: test.cpp: In instantiation of =E2=80=98T f(T) [with T =3D long double]=E2= =80=99: test.cpp:20:17: required from here test.cpp:12:12: error: call of overloaded =E2=80=98g(long double&)=E2=80=99= is ambiguous test.cpp:12:12: note: candidates are: test.cpp:3:6: note: char g(char) test.cpp:7:5: note: int g(int) even with -fpermissive=20 > (In reply to comment #6) > > The suggested work around in the error message 'adding -fpermissive' to > > gcc-4.7.0 does not fix the problem as suggested by the error message.=20 >=20 > As Manu says, -fpermissive changes the error to a warning, allowing the c= ode to > compile. Please check it again. >=20 > I'm going to close this, as I think G++ handles comment 1 correctly and b= oth > EDG and Clang agree. >=20 > I didn't check all your other examples in detail but I don't think they s= how > anything different: ADL doesn't find anything for built-in types such as = int or > char.