From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17392 invoked by alias); 5 Jun 2012 09:06:20 -0000 Received: (qmail 17377 invoked by uid 22791); 5 Jun 2012 09:06:18 -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 09:06:01 +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 09:06: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: major X-Bugzilla-Who: keean@fry-it.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: 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/msg00227.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D53573 --- Comment #6 from Keean Schupke 2012-06-05 09:06:01 UT= C --- 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. This would suggest the compiler is not displaying the correct error message for = the problem. g++ -fpermissive test.cpp Still generates: test.cpp: In instantiation of =E2=80=98T f(T) [with T =3D int]=E2=80=99: test.cpp:27:9: required from here test.cpp:18:12: error: =E2=80=98g=E2=80=99 was not declared in this scope, = and no declarations were found by argument-dependent lookup at the point of instantiation [-fpermissive] test.cpp:21:5: note: =E2=80=98int g(int)=E2=80=99 declared here, later in t= he translation unit A further test: int g(int x) { return x + 1; } char g(char x) { return x - 1; } template T f(T t) { return g((T)t); } double g(double x) { return x; } main() { double x(f(1.0L)); } generates the following compile time error: test.cpp: In instantiation of =E2=80=98T f(T) [with T =3D long double]=E2= =80=99: test.cpp:18:17: required from here test.cpp:10:15: error: call of overloaded =E2=80=98g(long double)=E2=80=99 = is ambiguous test.cpp:10:15: note: candidates are: test.cpp:1:5: note: int g(int) test.cpp:5:6: note: char g(char) Which is interesting as it suggests that the overloading of 'g' is happening from the definitions of 'g' that are in scope at the template definition. T= his is quite strange behaviour, as the compiler must have to capture a list all available overloads at the time of definition of each template. This looks = like a deliberate behaviour rather than a bug. So this looks more like a misunderstanding of the specification is the caus= e of this incorrect behaviour?