public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/99683] New: Deduction failure when using CTAD of CNTTP inside a deduction guide
@ 2021-03-20 17:27 omer.rosler at gmail dot com
2021-04-15 17:48 ` [Bug c++/99683] " omer.rosler at gmail dot com
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: omer.rosler at gmail dot com @ 2021-03-20 17:27 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99683
Bug ID: 99683
Summary: Deduction failure when using CTAD of CNTTP inside a
deduction guide
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: omer.rosler at gmail dot com
Target Milestone: ---
The following code causes a deduction failure on gcc and is accepted by clang.
It happens when using a CTAD for a CNTTP inside an explicit deduction guide.
I'm pretty sure it is legal C++20.
https://godbolt.org/z/Y49T6P
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/99683] Deduction failure when using CTAD of CNTTP inside a deduction guide
2021-03-20 17:27 [Bug c++/99683] New: Deduction failure when using CTAD of CNTTP inside a deduction guide omer.rosler at gmail dot com
@ 2021-04-15 17:48 ` omer.rosler at gmail dot com
2021-04-15 18:56 ` ppalka at gcc dot gnu.org
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: omer.rosler at gmail dot com @ 2021-04-15 17:48 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99683
--- Comment #1 from Omer Rosler <omer.rosler at gmail dot com> ---
It seems that
Reduced:
template<typename>
struct A
{
constexpr A(int) {}
};
A(int) -> A<int>;
template<A> //template<auto> works fine
struct B
{
template<typename T>
B(T);
};
template<typename T>
B(T) -> B<A{T{}}>; //see below
int main()
{
B t(42);
}
specifying A<T> explicitly also works, it's the deduction that triggers the bug
If the initializer of `A` is not dependent on the template parameter of the
guide (i.e `T`) than the bug isn't showing
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/99683] Deduction failure when using CTAD of CNTTP inside a deduction guide
2021-03-20 17:27 [Bug c++/99683] New: Deduction failure when using CTAD of CNTTP inside a deduction guide omer.rosler at gmail dot com
2021-04-15 17:48 ` [Bug c++/99683] " omer.rosler at gmail dot com
@ 2021-04-15 18:56 ` ppalka at gcc dot gnu.org
2021-04-24 4:15 ` cvs-commit at gcc dot gnu.org
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: ppalka at gcc dot gnu.org @ 2021-04-15 18:56 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99683
Patrick Palka <ppalka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
See Also| |https://gcc.gnu.org/bugzill
| |a/show_bug.cgi?id=93383
Status|UNCONFIRMED |NEW
CC| |ppalka at gcc dot gnu.org
Ever confirmed|0 |1
Last reconfirmed| |2021-04-15
--- Comment #2 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Thanks for the reduced testcases, confirmed. Closely related to PR93383 I
think.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/99683] Deduction failure when using CTAD of CNTTP inside a deduction guide
2021-03-20 17:27 [Bug c++/99683] New: Deduction failure when using CTAD of CNTTP inside a deduction guide omer.rosler at gmail dot com
2021-04-15 17:48 ` [Bug c++/99683] " omer.rosler at gmail dot com
2021-04-15 18:56 ` ppalka at gcc dot gnu.org
@ 2021-04-24 4:15 ` cvs-commit at gcc dot gnu.org
2021-04-27 21:24 ` cvs-commit at gcc dot gnu.org
2021-05-01 18:47 ` ppalka at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-04-24 4:15 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99683
--- Comment #3 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:bcd77b7b9f35bd5b559ed593c3b3e346c1e6f364
commit r12-100-gbcd77b7b9f35bd5b559ed593c3b3e346c1e6f364
Author: Patrick Palka <ppalka@redhat.com>
Date: Sat Apr 24 00:14:29 2021 -0400
c++: do_class_deduction and dependent init [PR93383]
Here we're crashing during CTAD with a dependent initializer (performed
from convert_template_argument) because one of the initializer's
elements has an empty TREE_TYPE, which ends up making resolve_args
unhappy.
Besides the case where we're initializing one template placeholder
from another, which is already specifically handled earlier in
do_class_deduction, it seems we can't in general correctly resolve a
template placeholder using a dependent initializer, so this patch makes
the function just punt until instantiation time instead.
gcc/cp/ChangeLog:
PR c++/89565
PR c++/93383
PR c++/95291
PR c++/99200
PR c++/99683
* pt.c (do_class_deduction): Punt if the initializer is
type-dependent.
gcc/testsuite/ChangeLog:
PR c++/89565
PR c++/93383
PR c++/95291
PR c++/99200
PR c++/99683
* g++.dg/cpp2a/nontype-class39.C: Remove dg-ice directive.
* g++.dg/cpp2a/nontype-class45.C: New test.
* g++.dg/cpp2a/nontype-class46.C: New test.
* g++.dg/cpp2a/nontype-class47.C: New test.
* g++.dg/cpp2a/nontype-class48.C: New test.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/99683] Deduction failure when using CTAD of CNTTP inside a deduction guide
2021-03-20 17:27 [Bug c++/99683] New: Deduction failure when using CTAD of CNTTP inside a deduction guide omer.rosler at gmail dot com
` (2 preceding siblings ...)
2021-04-24 4:15 ` cvs-commit at gcc dot gnu.org
@ 2021-04-27 21:24 ` cvs-commit at gcc dot gnu.org
2021-05-01 18:47 ` ppalka at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-04-27 21:24 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99683
--- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-11 branch has been updated by Patrick Palka
<ppalka@gcc.gnu.org>:
https://gcc.gnu.org/g:9532344edcf77c7c7b0fa5da31c1b9dd2850288e
commit r11-8309-g9532344edcf77c7c7b0fa5da31c1b9dd2850288e
Author: Patrick Palka <ppalka@redhat.com>
Date: Sat Apr 24 00:14:29 2021 -0400
c++: do_class_deduction and dependent init [PR93383]
Here we're crashing during CTAD with a dependent initializer (performed
from convert_template_argument) because one of the initializer's
elements has an empty TREE_TYPE, which ends up making resolve_args
unhappy.
Besides the case where we're initializing one template placeholder
from another, which is already specifically handled earlier in
do_class_deduction, it seems we can't in general correctly resolve a
template placeholder using a dependent initializer, so this patch makes
the function just punt until instantiation time instead.
gcc/cp/ChangeLog:
PR c++/89565
PR c++/93383
PR c++/95291
PR c++/99200
PR c++/99683
* pt.c (do_class_deduction): Punt if the initializer is
type-dependent.
gcc/testsuite/ChangeLog:
PR c++/89565
PR c++/93383
PR c++/95291
PR c++/99200
PR c++/99683
* g++.dg/cpp2a/nontype-class39.C: Remove dg-ice directive.
* g++.dg/cpp2a/nontype-class45.C: New test.
* g++.dg/cpp2a/nontype-class46.C: New test.
* g++.dg/cpp2a/nontype-class47.C: New test.
* g++.dg/cpp2a/nontype-class48.C: New test.
(cherry picked from commit bcd77b7b9f35bd5b559ed593c3b3e346c1e6f364)
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/99683] Deduction failure when using CTAD of CNTTP inside a deduction guide
2021-03-20 17:27 [Bug c++/99683] New: Deduction failure when using CTAD of CNTTP inside a deduction guide omer.rosler at gmail dot com
` (3 preceding siblings ...)
2021-04-27 21:24 ` cvs-commit at gcc dot gnu.org
@ 2021-05-01 18:47 ` ppalka at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: ppalka at gcc dot gnu.org @ 2021-05-01 18:47 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99683
Patrick Palka <ppalka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Target Milestone|--- |11.2
Resolution|--- |FIXED
--- Comment #5 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Fixed for GCC 11.2 and 12.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2021-05-01 18:47 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-20 17:27 [Bug c++/99683] New: Deduction failure when using CTAD of CNTTP inside a deduction guide omer.rosler at gmail dot com
2021-04-15 17:48 ` [Bug c++/99683] " omer.rosler at gmail dot com
2021-04-15 18:56 ` ppalka at gcc dot gnu.org
2021-04-24 4:15 ` cvs-commit at gcc dot gnu.org
2021-04-27 21:24 ` cvs-commit at gcc dot gnu.org
2021-05-01 18:47 ` 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).