From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15740 invoked by alias); 4 Jul 2012 16:39:17 -0000 Received: (qmail 15669 invoked by uid 22791); 4 Jul 2012 16:39:16 -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; Wed, 04 Jul 2012 16:39:03 +0000 From: "redi at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/53856] New: Default argument allowed on member defined outside of class template Date: Wed, 04 Jul 2012 16:39: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: redi 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" 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-07/txt/msg00480.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D53856 Bug #: 53856 Summary: Default argument allowed on member defined outside of class template 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: redi@gcc.gnu.org template struct A { struct B; }; template struct A::B { int i; }; int main() { A::B b =3D { }; return b.i; } This should be rejected according to [temp.param]/9 "A default template-argument shall not be specified in the template-parameter-lists of the definition of a member of a class template = that appears outside of the member=E2=80=99s class." All versions of G++ since at least 3.4 accept the code above. Comeau online rejects it: "ComeauTest.c", line 7: error: a default template argument cannot be specif= ied on the declaration of a member of a class template outside of its cl= ass template ^ As does Clang++ bug2.cc:7:19: error: cannot add a default template argument to the definiti= on of a member of a class template template ^ ~~~ Solaris CC accepts it.