public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/83476] [8/9/10/11 Regression] Template argument deduction fails with reference template parameter
[not found] <bug-83476-4@http.gcc.gnu.org/bugzilla/>
@ 2021-04-13 20:04 ` ppalka at gcc dot gnu.org
2021-04-13 20:04 ` ppalka at gcc dot gnu.org
` (9 subsequent siblings)
10 siblings, 0 replies; 11+ messages in thread
From: ppalka at gcc dot gnu.org @ 2021-04-13 20:04 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83476
Patrick Palka <ppalka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Known to work| |4.8.1
Summary|Template argument deduction |[8/9/10/11 Regression]
|fails with reference |Template argument deduction
|template parameter |fails with reference
| |template parameter
CC| |jason at gcc dot gnu.org,
| |ppalka at gcc dot gnu.org
Known to fail| |10.3.0, 11.0, 8.4.0, 9.3.0
Last reconfirmed| |2021-04-13
Ever confirmed|0 |1
Target Milestone|--- |8.5
Blocks| |99885
--- Comment #2 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Confirmed. C++98 testcase (essentially equivalent to comment #2, but without
brace initialization) which exhibits a regression starting with r0-128511
(4.9.0):
template <int& V> struct A {};
template <int& V> void f(A<V>);
int n;
int main() {
A<n> a;
f(a);
}
GCC 4.8 compiles the testcase successfully.
Referenced Bugs:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99885
[Bug 99885] CTAD fails for auto const& NTTP
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/83476] [8/9/10/11 Regression] Template argument deduction fails with reference template parameter
[not found] <bug-83476-4@http.gcc.gnu.org/bugzilla/>
2021-04-13 20:04 ` [Bug c++/83476] [8/9/10/11 Regression] Template argument deduction fails with reference template parameter ppalka at gcc dot gnu.org
@ 2021-04-13 20:04 ` ppalka at gcc dot gnu.org
2021-04-14 12:55 ` cvs-commit at gcc dot gnu.org
` (8 subsequent siblings)
10 siblings, 0 replies; 11+ messages in thread
From: ppalka at gcc dot gnu.org @ 2021-04-13 20:04 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83476
Patrick Palka <ppalka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |ASSIGNED
Assignee|unassigned at gcc dot gnu.org |ppalka at gcc dot gnu.org
--- Comment #3 from Patrick Palka <ppalka at gcc dot gnu.org> ---
I am testing:
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index c2b581c0f82..0a7397b742f 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -21898,8 +21898,10 @@ static bool uses_deducible_template_parms (tree type);
static bool
deducible_expression (tree expr)
{
- /* Strip implicit conversions. */
- while (CONVERT_EXPR_P (expr) || TREE_CODE (expr) == VIEW_CONVERT_EXPR)
+ /* Strip implicit conversions and implicit INDIRECT_REFs. */
+ while (CONVERT_EXPR_P (expr)
+ || TREE_CODE (expr) == VIEW_CONVERT_EXPR
+ || REFERENCE_REF_P (expr))
expr = TREE_OPERAND (expr, 0);
return (TREE_CODE (expr) == TEMPLATE_PARM_INDEX);
}
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/83476] [8/9/10/11 Regression] Template argument deduction fails with reference template parameter
[not found] <bug-83476-4@http.gcc.gnu.org/bugzilla/>
2021-04-13 20:04 ` [Bug c++/83476] [8/9/10/11 Regression] Template argument deduction fails with reference template parameter ppalka at gcc dot gnu.org
2021-04-13 20:04 ` ppalka at gcc dot gnu.org
@ 2021-04-14 12:55 ` cvs-commit at gcc dot gnu.org
2021-04-14 15:51 ` [Bug c++/83476] [8/9/10 " ppalka at gcc dot gnu.org
` (7 subsequent siblings)
10 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-04-14 12:55 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83476
--- Comment #4 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:2ccc05a5141506fde0e20dec702c717fd67bf6ee
commit r11-8175-g2ccc05a5141506fde0e20dec702c717fd67bf6ee
Author: Patrick Palka <ppalka@redhat.com>
Date: Wed Apr 14 08:54:30 2021 -0400
c++: Fix deduction with reference NTTP [PR83476]
In the testcase ref11.C below, during deduction for the call f(a),
uses_deducible_template_parms returns false for the dependent
specialization A<V> because the generic template argument V here is
wrapped in an implicit INDIRECT_REF (formed from template_parm_to_arg).
Since uses_deducible_template_parms returns false, unify_one_argument
exits early without ever attempting to deduce 'n' for 'V'. This patch
fixes this by making deducible_expression look through such implicit
INDIRECT_REFs.
gcc/cp/ChangeLog:
PR c++/83476
PR c++/99885
* pt.c (deducible_expression): Look through implicit
INDIRECT_REFs as well.
gcc/testsuite/ChangeLog:
PR c++/83476
PR c++/99885
* g++.dg/cpp1z/class-deduction85.C: New test.
* g++.dg/template/ref11.C: New test.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/83476] [8/9/10 Regression] Template argument deduction fails with reference template parameter
[not found] <bug-83476-4@http.gcc.gnu.org/bugzilla/>
` (2 preceding siblings ...)
2021-04-14 12:55 ` cvs-commit at gcc dot gnu.org
@ 2021-04-14 15:51 ` ppalka at gcc dot gnu.org
2021-04-20 16:09 ` cvs-commit at gcc dot gnu.org
` (6 subsequent siblings)
10 siblings, 0 replies; 11+ messages in thread
From: ppalka at gcc dot gnu.org @ 2021-04-14 15:51 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83476
Patrick Palka <ppalka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|[8/9/10/11 Regression] |[8/9/10 Regression]
|Template argument deduction |Template argument deduction
|fails with reference |fails with reference
|template parameter |template parameter
--- Comment #5 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Fixed for GCC 11 so far.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/83476] [8/9/10 Regression] Template argument deduction fails with reference template parameter
[not found] <bug-83476-4@http.gcc.gnu.org/bugzilla/>
` (3 preceding siblings ...)
2021-04-14 15:51 ` [Bug c++/83476] [8/9/10 " ppalka at gcc dot gnu.org
@ 2021-04-20 16:09 ` cvs-commit at gcc dot gnu.org
2021-04-30 7:43 ` [Bug c++/83476] [8/9 " rguenth at gcc dot gnu.org
` (5 subsequent siblings)
10 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-04-20 16:09 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83476
--- Comment #6 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-10 branch has been updated by Patrick Palka
<ppalka@gcc.gnu.org>:
https://gcc.gnu.org/g:904cbf6ae2a1e45b3a272365cca19f9dd9a27fa2
commit r10-9733-g904cbf6ae2a1e45b3a272365cca19f9dd9a27fa2
Author: Patrick Palka <ppalka@redhat.com>
Date: Tue Apr 20 12:06:24 2021 -0400
c++: Fix deduction with reference NTTP [PR83476]
In the testcase ref11.C below, during deduction for the call f(a),
uses_deducible_template_parms returns false for the dependent
specialization A<V> because the generic template argument V here is
wrapped in an implicit INDIRECT_REF (formed from template_parm_to_arg).
Since uses_deducible_template_parms returns false, unify_one_argument
exits early without ever attempting to deduce 'n' for 'V'. This patch
fixes this by making deducible_expression look through such implicit
INDIRECT_REFs.
gcc/cp/ChangeLog:
PR c++/83476
PR c++/99885
* pt.c (deducible_expression): Look through implicit
INDIRECT_REFs as well.
gcc/testsuite/ChangeLog:
PR c++/83476
PR c++/99885
* g++.dg/cpp1z/class-deduction85.C: New test.
* g++.dg/template/ref11.C: New test.
(cherry picked from commit 2ccc05a5141506fde0e20dec702c717fd67bf6ee)
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/83476] [8/9 Regression] Template argument deduction fails with reference template parameter
[not found] <bug-83476-4@http.gcc.gnu.org/bugzilla/>
` (4 preceding siblings ...)
2021-04-20 16:09 ` cvs-commit at gcc dot gnu.org
@ 2021-04-30 7:43 ` rguenth at gcc dot gnu.org
2021-05-14 9:49 ` [Bug c++/83476] [9 " jakub at gcc dot gnu.org
` (4 subsequent siblings)
10 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-04-30 7:43 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83476
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Priority|P3 |P2
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/83476] [9 Regression] Template argument deduction fails with reference template parameter
[not found] <bug-83476-4@http.gcc.gnu.org/bugzilla/>
` (5 preceding siblings ...)
2021-04-30 7:43 ` [Bug c++/83476] [8/9 " rguenth at gcc dot gnu.org
@ 2021-05-14 9:49 ` jakub at gcc dot gnu.org
2021-06-01 8:09 ` rguenth at gcc dot gnu.org
` (3 subsequent siblings)
10 siblings, 0 replies; 11+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-05-14 9:49 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83476
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|8.5 |9.4
--- Comment #7 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
GCC 8 branch is being closed.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/83476] [9 Regression] Template argument deduction fails with reference template parameter
[not found] <bug-83476-4@http.gcc.gnu.org/bugzilla/>
` (6 preceding siblings ...)
2021-05-14 9:49 ` [Bug c++/83476] [9 " jakub at gcc dot gnu.org
@ 2021-06-01 8:09 ` rguenth at gcc dot gnu.org
2021-12-08 19:03 ` pinskia at gcc dot gnu.org
` (2 subsequent siblings)
10 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-06-01 8:09 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83476
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|9.4 |9.5
--- Comment #8 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 9.4 is being released, retargeting bugs to GCC 9.5.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/83476] [9 Regression] Template argument deduction fails with reference template parameter
[not found] <bug-83476-4@http.gcc.gnu.org/bugzilla/>
` (7 preceding siblings ...)
2021-06-01 8:09 ` rguenth at gcc dot gnu.org
@ 2021-12-08 19:03 ` pinskia at gcc dot gnu.org
2022-05-11 14:59 ` cvs-commit at gcc dot gnu.org
2022-05-11 15:01 ` ppalka at gcc dot gnu.org
10 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-12-08 19:03 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83476
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |vittorio.romeo at outlook dot com
--- Comment #9 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
*** Bug 80651 has been marked as a duplicate of this bug. ***
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/83476] [9 Regression] Template argument deduction fails with reference template parameter
[not found] <bug-83476-4@http.gcc.gnu.org/bugzilla/>
` (8 preceding siblings ...)
2021-12-08 19:03 ` pinskia at gcc dot gnu.org
@ 2022-05-11 14:59 ` cvs-commit at gcc dot gnu.org
2022-05-11 15:01 ` ppalka at gcc dot gnu.org
10 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-05-11 14:59 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83476
--- Comment #10 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-9 branch has been updated by Patrick Palka
<ppalka@gcc.gnu.org>:
https://gcc.gnu.org/g:c6432e17960799509c48df6b500a8d069110980b
commit r9-10154-gc6432e17960799509c48df6b500a8d069110980b
Author: Patrick Palka <ppalka@redhat.com>
Date: Wed Apr 14 08:54:30 2021 -0400
c++: Fix deduction with reference NTTP [PR83476]
In the testcase ref11.C below, during deduction for the call f(a),
uses_deducible_template_parms returns false for the dependent
specialization A<V> because the generic template argument V here is
wrapped in an implicit INDIRECT_REF (formed from template_parm_to_arg).
Since uses_deducible_template_parms returns false, unify_one_argument
exits early without ever attempting to deduce 'n' for 'V'. This patch
fixes this by making deducible_expression look through such implicit
INDIRECT_REFs.
gcc/cp/ChangeLog:
PR c++/83476
PR c++/99885
* pt.c (deducible_expression): Look through implicit
INDIRECT_REFs as well.
gcc/testsuite/ChangeLog:
PR c++/83476
PR c++/99885
* g++.dg/cpp1z/class-deduction85.C: New test.
* g++.dg/template/ref11.C: New test.
(cherry picked from commit 2ccc05a5141506fde0e20dec702c717fd67bf6ee)
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/83476] [9 Regression] Template argument deduction fails with reference template parameter
[not found] <bug-83476-4@http.gcc.gnu.org/bugzilla/>
` (9 preceding siblings ...)
2022-05-11 14:59 ` cvs-commit at gcc dot gnu.org
@ 2022-05-11 15:01 ` ppalka at gcc dot gnu.org
10 siblings, 0 replies; 11+ messages in thread
From: ppalka at gcc dot gnu.org @ 2022-05-11 15:01 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83476
Patrick Palka <ppalka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution|--- |FIXED
--- Comment #11 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Should be fixed for 9.5, 10.4, and 11/12.
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2022-05-11 15:01 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <bug-83476-4@http.gcc.gnu.org/bugzilla/>
2021-04-13 20:04 ` [Bug c++/83476] [8/9/10/11 Regression] Template argument deduction fails with reference template parameter ppalka at gcc dot gnu.org
2021-04-13 20:04 ` ppalka at gcc dot gnu.org
2021-04-14 12:55 ` cvs-commit at gcc dot gnu.org
2021-04-14 15:51 ` [Bug c++/83476] [8/9/10 " ppalka at gcc dot gnu.org
2021-04-20 16:09 ` cvs-commit at gcc dot gnu.org
2021-04-30 7:43 ` [Bug c++/83476] [8/9 " rguenth at gcc dot gnu.org
2021-05-14 9:49 ` [Bug c++/83476] [9 " jakub at gcc dot gnu.org
2021-06-01 8:09 ` rguenth at gcc dot gnu.org
2021-12-08 19:03 ` pinskia at gcc dot gnu.org
2022-05-11 14:59 ` cvs-commit at gcc dot gnu.org
2022-05-11 15:01 ` 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).