public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/65396] New: Function template default template arguments not merged
@ 2015-03-12 2:49 david at stellarscience dot com
2015-03-12 11:11 ` [Bug c++/65396] " redi at gcc dot gnu.org
` (8 more replies)
0 siblings, 9 replies; 10+ messages in thread
From: david at stellarscience dot com @ 2015-03-12 2:49 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65396
Bug ID: 65396
Summary: Function template default template arguments not
merged
Product: gcc
Version: 4.9.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: david at stellarscience dot com
template <typename T, T *> void f();
template <typename T, T * = nullptr> void f() {}
int main() { f<int>(); }
------------------------
gcc inaccurately rejects this program, which is violating the following
sentence from [C++11 14.1 p10]
The set of default template-arguments available for use with a template
declaration or definition is obtained by merging the default arguments from the
definition (if in scope) and all declarations in scope in the same way default
function arguments are (8.3.6).
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/65396] Function template default template arguments not merged
2015-03-12 2:49 [Bug c++/65396] New: Function template default template arguments not merged david at stellarscience dot com
@ 2015-03-12 11:11 ` redi at gcc dot gnu.org
2021-08-05 8:58 ` pinskia at gcc dot gnu.org
` (7 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: redi at gcc dot gnu.org @ 2015-03-12 11:11 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65396
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |rejects-valid
Status|UNCONFIRMED |NEW
Last reconfirmed| |2015-03-12
Ever confirmed|0 |1
--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Presumably this rule was never implemented for function templates when they
started being allowed default template arguments.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/65396] Function template default template arguments not merged
2015-03-12 2:49 [Bug c++/65396] New: Function template default template arguments not merged david at stellarscience dot com
2015-03-12 11:11 ` [Bug c++/65396] " redi at gcc dot gnu.org
@ 2021-08-05 8:58 ` pinskia at gcc dot gnu.org
2021-08-05 9:01 ` pinskia at gcc dot gnu.org
` (6 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-08-05 8:58 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65396
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |devgs at ukr dot net
--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
*** Bug 80771 has been marked as a duplicate of this bug. ***
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/65396] Function template default template arguments not merged
2015-03-12 2:49 [Bug c++/65396] New: Function template default template arguments not merged david at stellarscience dot com
2015-03-12 11:11 ` [Bug c++/65396] " redi at gcc dot gnu.org
2021-08-05 8:58 ` pinskia at gcc dot gnu.org
@ 2021-08-05 9:01 ` pinskia at gcc dot gnu.org
2021-08-05 9:03 ` pinskia at gcc dot gnu.org
` (5 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-08-05 9:01 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65396
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |Predelnik at gmail dot com
--- Comment #6 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
*** Bug 93415 has been marked as a duplicate of this bug. ***
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/65396] Function template default template arguments not merged
2015-03-12 2:49 [Bug c++/65396] New: Function template default template arguments not merged david at stellarscience dot com
` (2 preceding siblings ...)
2021-08-05 9:01 ` pinskia at gcc dot gnu.org
@ 2021-08-05 9:03 ` pinskia at gcc dot gnu.org
2021-09-12 20:07 ` pinskia at gcc dot gnu.org
` (4 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-08-05 9:03 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65396
--- Comment #7 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
The testcase from PR 93415 shows this can produce wrong code too:
template <bool B>
void f (int);
template <bool B = true>
void f (int) {}
template <bool B = true>
void f (char) { __builtin_abort (); }
int main ()
{
f (0);
return 0;
}
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/65396] Function template default template arguments not merged
2015-03-12 2:49 [Bug c++/65396] New: Function template default template arguments not merged david at stellarscience dot com
` (3 preceding siblings ...)
2021-08-05 9:03 ` pinskia at gcc dot gnu.org
@ 2021-09-12 20:07 ` pinskia at gcc dot gnu.org
2021-09-12 20:08 ` pinskia at gcc dot gnu.org
` (3 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-09-12 20:07 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65396
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |sp2danny at gmail dot com
--- Comment #8 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
*** Bug 87279 has been marked as a duplicate of this bug. ***
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/65396] Function template default template arguments not merged
2015-03-12 2:49 [Bug c++/65396] New: Function template default template arguments not merged david at stellarscience dot com
` (4 preceding siblings ...)
2021-09-12 20:07 ` pinskia at gcc dot gnu.org
@ 2021-09-12 20:08 ` pinskia at gcc dot gnu.org
2022-03-03 20:07 ` ppalka at gcc dot gnu.org
` (2 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-09-12 20:08 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65396
--- Comment #9 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Another simplified testcase:
template<class T> void f();
template<class T=int> void f() {}
int main() { f(); }
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/65396] Function template default template arguments not merged
2015-03-12 2:49 [Bug c++/65396] New: Function template default template arguments not merged david at stellarscience dot com
` (5 preceding siblings ...)
2021-09-12 20:08 ` pinskia at gcc dot gnu.org
@ 2022-03-03 20:07 ` ppalka at gcc dot gnu.org
2022-03-09 13:44 ` cvs-commit at gcc dot gnu.org
2022-03-09 13:46 ` ppalka at gcc dot gnu.org
8 siblings, 0 replies; 10+ messages in thread
From: ppalka at gcc dot gnu.org @ 2022-03-03 20:07 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65396
Patrick Palka <ppalka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |ppalka at gcc dot gnu.org
Assignee|unassigned at gcc dot gnu.org |ppalka at gcc dot gnu.org
Status|NEW |ASSIGNED
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/65396] Function template default template arguments not merged
2015-03-12 2:49 [Bug c++/65396] New: Function template default template arguments not merged david at stellarscience dot com
` (6 preceding siblings ...)
2022-03-03 20:07 ` ppalka at gcc dot gnu.org
@ 2022-03-09 13:44 ` cvs-commit at gcc dot gnu.org
2022-03-09 13:46 ` ppalka at gcc dot gnu.org
8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-03-09 13:44 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65396
--- Comment #10 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Patrick Palka <ppalka@gcc.gnu.org>:
https://gcc.gnu.org/g:fe548eb8436f3906e6a3c6e3e8707d24e60ec0fa
commit r12-7562-gfe548eb8436f3906e6a3c6e3e8707d24e60ec0fa
Author: Patrick Palka <ppalka@redhat.com>
Date: Wed Mar 9 08:42:19 2022 -0500
c++: merge default targs for function templates [PR65396]
We currently merge default template arguments for class templates, but
not for function templates. This patch fixes this by factoring out the
argument merging logic in redeclare_class_template into a separate
function and using it in duplicate_decls as well.
PR c++/65396
gcc/cp/ChangeLog:
* cp-tree.h (merge_default_template_args): Declare.
* decl.cc (merge_default_template_args): Define, factored out
from redeclare_class_template.
(duplicate_decls): Use it when merging member function template
and free function declarations.
* pt.cc (redeclare_class_template): Factor out default argument
merging logic into merge_default_template_args. Improve location
of a note when there's a template parameter kind mismatch.
gcc/testsuite/ChangeLog:
* g++.dg/cpp0x/vt-34314.C: Adjust expected location of
"redeclared here" note.
* g++.dg/template/pr92440.C: Likewise.
* g++.old-deja/g++.pt/redecl1.C: Adjust expected location of
"redefinition of default argument" error.
* g++.dg/template/defarg23.C: New test.
* g++.dg/template/defarg23a.C: New test.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/65396] Function template default template arguments not merged
2015-03-12 2:49 [Bug c++/65396] New: Function template default template arguments not merged david at stellarscience dot com
` (7 preceding siblings ...)
2022-03-09 13:44 ` cvs-commit at gcc dot gnu.org
@ 2022-03-09 13:46 ` ppalka at gcc dot gnu.org
8 siblings, 0 replies; 10+ messages in thread
From: ppalka at gcc dot gnu.org @ 2022-03-09 13:46 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65396
Patrick Palka <ppalka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |12.0
Status|ASSIGNED |RESOLVED
Resolution|--- |FIXED
--- Comment #11 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Fixed for GCC 12.
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2022-03-09 13:46 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-12 2:49 [Bug c++/65396] New: Function template default template arguments not merged david at stellarscience dot com
2015-03-12 11:11 ` [Bug c++/65396] " redi at gcc dot gnu.org
2021-08-05 8:58 ` pinskia at gcc dot gnu.org
2021-08-05 9:01 ` pinskia at gcc dot gnu.org
2021-08-05 9:03 ` pinskia at gcc dot gnu.org
2021-09-12 20:07 ` pinskia at gcc dot gnu.org
2021-09-12 20:08 ` pinskia at gcc dot gnu.org
2022-03-03 20:07 ` ppalka at gcc dot gnu.org
2022-03-09 13:44 ` cvs-commit at gcc dot gnu.org
2022-03-09 13:46 ` ppalka at gcc dot gnu.org
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).