public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/54485] New: g++ should diagnose default arguments in out-of-line definitions for template class member functions
@ 2012-09-04 21:27 dnovillo at gcc dot gnu.org
  2012-09-05  7:27 ` [Bug c++/54485] " thiago at kde dot org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: dnovillo at gcc dot gnu.org @ 2012-09-04 21:27 UTC (permalink / raw)
  To: gcc-bugs

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<typename T>
class K
{
  int fn(int, int);
};

template<typename T>
int K<T>::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<T>::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


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2013-11-25 22:26 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-09-04 21:27 [Bug c++/54485] New: g++ should diagnose default arguments in out-of-line definitions for template class member functions dnovillo at gcc dot gnu.org
2012-09-05  7:27 ` [Bug c++/54485] " thiago at kde dot org
2012-09-05  9:20 ` rguenth at gcc dot gnu.org
2013-10-28 13:59 ` paolo.carlini at oracle dot com
2013-11-25 22:25 ` paolo at gcc dot gnu.org
2013-11-25 22:26 ` paolo.carlini at oracle dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).