From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2253 invoked by alias); 10 May 2013 17:37:39 -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 2237 invoked by uid 48); 10 May 2013 17:37:36 -0000 From: "w.shane.grant at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/57243] New: Using auto in range based for with templated container in templated function requires extraneous template qualifier Date: Fri, 10 May 2013 17:37: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-Version: 4.8.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: w.shane.grant at gmail 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-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2013-05/txt/msg00726.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57243 Bug ID: 57243 Summary: Using auto in range based for with templated container in templated function requires extraneous template qualifier Product: gcc Version: 4.8.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: w.shane.grant at gmail dot com Using the auto keyword in a range based for loop under three conditions related to templating requires an unnecessary use of the template qualifier for compilation to happen successfully: 1. The container being iterated is templated 2. The range based for loop is inside of a template function 3. The iterated item has a template function Here is a minimal example: struct snarf { template void get() {} }; template struct container { snarf * begin() { return nullptr; } snarf * end() { return nullptr; } }; template void foo() { container arr; for( auto i : arr ) i.get(); } int main() { return 0; } The issue goes away if any of the following happen: - foo is made a non template function - arr is made a non template container - auto is replaced with the actual type (snarf in this example) - the function called on the range declaration (i) is not templated - the template keyword is used to disambiguate the call to get - the range based for loop is replaced with a standard for loop over the iterators (auto works fine here) Issue seems to happen with both versions of g++ I have installed (4.7.3 and g++ 4.8.1 20130401) but not under clang (version 3.3 (trunk 178896)).