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
* [Bug c++/54485] g++ should diagnose default arguments in out-of-line definitions for template class member functions
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 ` thiago at kde dot org
2012-09-05 9:20 ` rguenth at gcc dot gnu.org
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: thiago at kde dot org @ 2012-09-05 7:27 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54485
Thiago Macieira <thiago at kde dot org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |thiago at kde dot org
--- Comment #1 from Thiago Macieira <thiago at kde dot org> 2012-09-05 07:27:08 UTC ---
FYI
$ icpc -c a.cc
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/54485] g++ should diagnose default arguments in out-of-line definitions for template class member functions
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
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: rguenth at gcc dot gnu.org @ 2012-09-05 9:20 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54485
Richard Guenther <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2012-09-05
Ever Confirmed|0 |1
--- Comment #2 from Richard Guenther <rguenth at gcc dot gnu.org> 2012-09-05 09:20:27 UTC ---
Confirmed. Probably worth accepting with -fpermissive?
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/54485] g++ should diagnose default arguments in out-of-line definitions for template class member functions
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
4 siblings, 0 replies; 6+ messages in thread
From: paolo.carlini at oracle dot com @ 2013-10-28 13:59 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54485
--- Comment #4 from Paolo Carlini <paolo.carlini at oracle dot com> ---
Patch here: http://gcc.gnu.org/ml/gcc-patches/2013-08/msg01435.html
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/54485] g++ should diagnose default arguments in out-of-line definitions for template class member functions
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
` (2 preceding siblings ...)
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
4 siblings, 0 replies; 6+ messages in thread
From: paolo at gcc dot gnu.org @ 2013-11-25 22:25 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54485
--- Comment #5 from paolo at gcc dot gnu.org <paolo at gcc dot gnu.org> ---
Author: paolo
Date: Mon Nov 25 22:24:58 2013
New Revision: 205367
URL: http://gcc.gnu.org/viewcvs?rev=205367&root=gcc&view=rev
Log:
/cp
2013-11-25 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/54485
* decl.c (duplicate_decls): Enforce 8.3.6/6 about default arguments
for member functions of class templates.
/testsuite
2013-11-25 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/54485
* g++.dg/other/default8.C: New.
* g++.dg/tc1/dr217.C: Remove xfail.
* g++.dg/other/default5.C: Adjust.
* g++.old-deja/g++.mike/p1989.C: Likewise.
Added:
trunk/gcc/testsuite/g++.dg/other/default8.C
Modified:
trunk/gcc/cp/ChangeLog
trunk/gcc/cp/decl.c
trunk/gcc/testsuite/ChangeLog
trunk/gcc/testsuite/g++.dg/other/default5.C
trunk/gcc/testsuite/g++.dg/tc1/dr217.C
trunk/gcc/testsuite/g++.old-deja/g++.mike/p1989.C
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/54485] g++ should diagnose default arguments in out-of-line definitions for template class member functions
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
` (3 preceding siblings ...)
2013-11-25 22:25 ` paolo at gcc dot gnu.org
@ 2013-11-25 22:26 ` paolo.carlini at oracle dot com
4 siblings, 0 replies; 6+ messages in thread
From: paolo.carlini at oracle dot com @ 2013-11-25 22:26 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54485
Paolo Carlini <paolo.carlini at oracle dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution|--- |FIXED
Assignee|paolo.carlini at oracle dot com |unassigned at gcc dot gnu.org
--- Comment #6 from Paolo Carlini <paolo.carlini at oracle dot com> ---
Fixed for 4.9.0.
^ 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).