From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4160 invoked by alias); 5 Jun 2012 11:26:00 -0000 Received: (qmail 3986 invoked by uid 22791); 5 Jun 2012 11:25:53 -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:25:41 +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:26: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" 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/msg00239.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53573 --- Comment #13 from Keean Schupke 2012-06-05 11:25:40 UTC --- (In reply to comment #9) >>From ISO14882 14.6 - Name resolution [temp.res] -8- When looking for the declaration of a name used in a template definition, the usual lookup rules (basic.lookup.unqual, basic.lookup.koenig) are used for nondependent names. The lookup of names dependent on the template parameters is postponed until the actual template argument is known (temp.dep). [Example: #include using namespace std; template class Set { T* p; int cnt; public: Set(); Set(const Set&); void printall() { for (int i = 0; i, the actual declaration of operator<< needed to print p[i] cannot be known until it is known what type T is (temp.dep). ] -9- If a name does not depend on a template-parameter (as defined in temp.dep), a declaration (or set of declarations) for that name shall be in scope at the point where the name appears in the template definition; the name is bound to the declaration (or declarations) found at that point and this binding is not affected by declarations that are visible at the point of instantiation. [Example: void f(char); template void g(T t) { f(1); // f(char) f(T(1)); // dependent f(t); // dependent dd++; // not dependent // error: declaration for dd not found } void f(int); double dd; void h() { g(2); // will cause one call of f(char) followed // by two calls of f(int) g('a'); // will cause three calls of f(char) } So it was like this in 1998, and it is the same in the latest working draft. --- end example] > (In reply to comment #2) > > The function called in the template definition is clearly dependent on the > > template parameter 'T' and therefore itsname should be resolved at the point of > > instantiation where 'g' is clearly defined and in scope (and is not local). The > > error message says: "no declarations were found by argument-dependent lookup at > > the point of instantiation" when 'g' should be found. > > Built-in types have no associated namespaces so ADL can not find 'g' via ADL. A > declaration must be visible at the point of definition. > > The example in comment 1 is ill-formed. > > Paragraph 10 doesn't apply because the call is clearly dependent. > > N.B. N3242 is not the C++ standard and neither is "C++ Special Edition" which > is quite old now.