public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/99885] New: CTAD fails for auto const& NTTP
@ 2021-04-02 21:47 ldalessandro at gmail dot com
2021-04-13 19:14 ` [Bug c++/99885] " ppalka at gcc dot gnu.org
` (7 more replies)
0 siblings, 8 replies; 9+ messages in thread
From: ldalessandro at gmail dot com @ 2021-04-02 21:47 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99885
Bug ID: 99885
Summary: CTAD fails for auto const& NTTP
Product: gcc
Version: 11.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: ldalessandro at gmail dot com
Target Milestone: ---
Following (much-reduced) code causes a CTAD failure in gcc but not clang
(https://godbolt.org/z/zWhWGj7PE) with both C++17 and C++20.
template <auto const& A>
struct Foo {};
template <auto const& A>
struct Bar {
constexpr auto foo() const -> Foo<A> {
return {};
}
};
constexpr int a = 1;
constexpr Bar<a> bar;
Foo foo = bar.foo(); // <-- CTAD failure
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/99885] CTAD fails for auto const& NTTP
2021-04-02 21:47 [Bug c++/99885] New: CTAD fails for auto const& NTTP ldalessandro at gmail dot com
@ 2021-04-13 19:14 ` ppalka at gcc dot gnu.org
2021-04-14 12:55 ` cvs-commit at gcc dot gnu.org
` (6 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: ppalka at gcc dot gnu.org @ 2021-04-13 19:14 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99885
Patrick Palka <ppalka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |ASSIGNED
CC| |ppalka at gcc dot gnu.org
Last reconfirmed| |2021-04-13
Ever confirmed|0 |1
Assignee|unassigned at gcc dot gnu.org |ppalka at gcc dot gnu.org
--- Comment #1 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Confirmed, this never worked. Reduced:
template <int& V> struct A {};
int n = 1;
A a = A<n>{};
Looking into it.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/99885] CTAD fails for auto const& NTTP
2021-04-02 21:47 [Bug c++/99885] New: CTAD fails for auto const& NTTP ldalessandro at gmail dot com
2021-04-13 19:14 ` [Bug c++/99885] " ppalka at gcc dot gnu.org
@ 2021-04-14 12:55 ` cvs-commit at gcc dot gnu.org
2021-04-14 14:07 ` ppalka at gcc dot gnu.org
` (5 subsequent siblings)
7 siblings, 0 replies; 9+ 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=99885
--- Comment #2 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] 9+ messages in thread
* [Bug c++/99885] CTAD fails for auto const& NTTP
2021-04-02 21:47 [Bug c++/99885] New: CTAD fails for auto const& NTTP ldalessandro at gmail dot com
2021-04-13 19:14 ` [Bug c++/99885] " ppalka at gcc dot gnu.org
2021-04-14 12:55 ` cvs-commit at gcc dot gnu.org
@ 2021-04-14 14:07 ` ppalka at gcc dot gnu.org
2021-04-14 14:39 ` ppalka at gcc dot gnu.org
` (4 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: ppalka at gcc dot gnu.org @ 2021-04-14 14:07 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99885
Patrick Palka <ppalka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution|--- |FIXED
--- Comment #3 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Thanks for the bug report, this is now fixed for GCC 11. The underlying bug is
7 regression from the 4.9 era and is being tracked at PR83476.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/99885] CTAD fails for auto const& NTTP
2021-04-02 21:47 [Bug c++/99885] New: CTAD fails for auto const& NTTP ldalessandro at gmail dot com
` (2 preceding siblings ...)
2021-04-14 14:07 ` ppalka at gcc dot gnu.org
@ 2021-04-14 14:39 ` ppalka at gcc dot gnu.org
2021-04-20 16:09 ` cvs-commit at gcc dot gnu.org
` (3 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: ppalka at gcc dot gnu.org @ 2021-04-14 14:39 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99885
Patrick Palka <ppalka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |11.0
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/99885] CTAD fails for auto const& NTTP
2021-04-02 21:47 [Bug c++/99885] New: CTAD fails for auto const& NTTP ldalessandro at gmail dot com
` (3 preceding siblings ...)
2021-04-14 14:39 ` ppalka at gcc dot gnu.org
@ 2021-04-20 16:09 ` cvs-commit at gcc dot gnu.org
2022-05-11 14:59 ` cvs-commit at gcc dot gnu.org
` (2 subsequent siblings)
7 siblings, 0 replies; 9+ 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=99885
--- Comment #4 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] 9+ messages in thread
* [Bug c++/99885] CTAD fails for auto const& NTTP
2021-04-02 21:47 [Bug c++/99885] New: CTAD fails for auto const& NTTP ldalessandro at gmail dot com
` (4 preceding siblings ...)
2021-04-20 16:09 ` cvs-commit 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
2022-05-11 15:02 ` ppalka at gcc dot gnu.org
7 siblings, 0 replies; 9+ 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=99885
--- Comment #5 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] 9+ messages in thread
* [Bug c++/99885] CTAD fails for auto const& NTTP
2021-04-02 21:47 [Bug c++/99885] New: CTAD fails for auto const& NTTP ldalessandro at gmail dot com
` (5 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
2022-05-11 15:02 ` ppalka at gcc dot gnu.org
7 siblings, 0 replies; 9+ 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=99885
Bug 99885 depends on bug 83476, which changed state.
Bug 83476 Summary: [9 Regression] Template argument deduction fails with reference template parameter
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83476
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution|--- |FIXED
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/99885] CTAD fails for auto const& NTTP
2021-04-02 21:47 [Bug c++/99885] New: CTAD fails for auto const& NTTP ldalessandro at gmail dot com
` (6 preceding siblings ...)
2022-05-11 15:01 ` ppalka at gcc dot gnu.org
@ 2022-05-11 15:02 ` ppalka at gcc dot gnu.org
7 siblings, 0 replies; 9+ messages in thread
From: ppalka at gcc dot gnu.org @ 2022-05-11 15:02 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99885
Patrick Palka <ppalka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|11.0 |9.5
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2022-05-11 15:02 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-02 21:47 [Bug c++/99885] New: CTAD fails for auto const& NTTP ldalessandro at gmail dot com
2021-04-13 19:14 ` [Bug c++/99885] " ppalka at gcc dot gnu.org
2021-04-14 12:55 ` cvs-commit at gcc dot gnu.org
2021-04-14 14:07 ` ppalka at gcc dot gnu.org
2021-04-14 14:39 ` ppalka at gcc dot gnu.org
2021-04-20 16:09 ` cvs-commit 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
2022-05-11 15:02 ` 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).