From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25463 invoked by alias); 20 Mar 2014 22:04:22 -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 25430 invoked by uid 48); 20 Mar 2014 22:04:17 -0000 From: "public at alisdairm dot net" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/60605] New: incorrect diagosis of default template argument for function declaration inside class template member function Date: Thu, 20 Mar 2014 22:04: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: public at alisdairm dot net 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: 2014-03/txt/msg01922.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60605 Bug ID: 60605 Summary: incorrect diagosis of default template argument for function declaration inside class template member function Product: gcc Version: 4.8.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: public at alisdairm dot net This bug looks looks obscure, but breaks our 'static assert' facility for C++03 compilers (after applying a workaround for the gcc 4.8 unused typedef warning): template struct Foo { void bar() { void bug(); } }; This should simply be declaring 'bug' as a function in the enclosing namespace, the default template parameter on the class template is irrelevant, 'bug' is neither a function template nor a member function of a class template. With g++ -std=c++03 I get: main.cpp: In member function 'void Foo::bar()': main.cpp:4:18: error: default template arguments may not be used in function templates without -std=c++11 or -std=gnu++11 void bug(); ^ With g++ -std=c++11 I get: main.cpp: In member function 'void Foo::bar()': main.cpp:4:18: error: default argument for template parameter for class enclosing 'void bug()' void bug(); ^ I am not sure what language rule the C++11 switch thinks it is diagnosing, this code is accepted by the Clang compiler which I used as a cross-check.