From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 32533 invoked by alias); 4 Sep 2012 21:27:43 -0000 Received: (qmail 32470 invoked by uid 22791); 4 Sep 2012 21:27:41 -0000 X-SWARE-Spam-Status: No, hits=-3.6 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 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, 04 Sep 2012 21:27:28 +0000 From: "dnovillo at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/54485] New: g++ should diagnose default arguments in out-of-line definitions for template class member functions Date: Tue, 04 Sep 2012 21:27: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-Keywords: accepts-invalid X-Bugzilla-Severity: normal X-Bugzilla-Who: dnovillo at gcc dot gnu.org 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: 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-09/txt/msg00297.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54485 Bug #: 54485 Summary: g++ should diagnose default arguments in out-of-line definitions for template class member functions Classification: Unclassified Product: gcc Version: 4.8.0 Status: UNCONFIRMED Keywords: accepts-invalid Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned@gcc.gnu.org ReportedBy: dnovillo@gcc.gnu.org CC: jason@gcc.gnu.org In PR 54484, bootstraps were broken with clang++. The template class vec_t had a member function with default arguments, but the default values were specified in the function definition, instead of its declaration. According to 8.3.6, that's incorrect: "Default arguments for a member function of a class template shall be specified on the initial declaration of the member function within the class template." $ cat a.cc template class K { int fn(int, int); }; template int K::fn (int a, int b = 3) { return a - b; } $ g++ -c a.cc $ clang++ -c a.cc a.cc:8:26: error: default arguments cannot be added to an out-of-line definition of a member of a class template int K::fn (int a, int b = 3) ^ ~ 1 error generated. $ g++ --version g++ (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3 Copyright (C) 2011 Free Software Foundation, Inc.This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. $ clang++ --version Ubuntu clang version 3.0-6ubuntu3 (tags/RELEASE_30/final) (based on LLVM 3.0)Target: x86_64-pc-linux-gnu Thread model: posix