public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/95568] New: No CTAD with list initialization within requires-clause
@ 2020-06-08 2:17 johelegp at gmail dot com
2020-06-16 19:51 ` [Bug c++/95568] " ppalka at gcc dot gnu.org
` (6 more replies)
0 siblings, 7 replies; 8+ messages in thread
From: johelegp at gmail dot com @ 2020-06-08 2:17 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95568
Bug ID: 95568
Summary: No CTAD with list initialization within
requires-clause
Product: gcc
Version: 10.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: johelegp at gmail dot com
Target Milestone: ---
See https://godbolt.org/z/Ljt-85.
```C++
template<class T> struct X { T x; };
template<class T> concept Y = requires { X{0}; };
```
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/95568] No CTAD with list initialization within requires-clause
2020-06-08 2:17 [Bug c++/95568] New: No CTAD with list initialization within requires-clause johelegp at gmail dot com
@ 2020-06-16 19:51 ` ppalka at gcc dot gnu.org
2020-06-18 19:47 ` mpolacek at gcc dot gnu.org
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: ppalka at gcc dot gnu.org @ 2020-06-16 19:51 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95568
Patrick Palka <ppalka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |10.2
Last reconfirmed| |2020-06-16
Status|UNCONFIRMED |NEW
CC| |ppalka at gcc dot gnu.org
Ever confirmed|0 |1
--- Comment #1 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Confirmed.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/95568] No CTAD with list initialization within requires-clause
2020-06-08 2:17 [Bug c++/95568] New: No CTAD with list initialization within requires-clause johelegp at gmail dot com
2020-06-16 19:51 ` [Bug c++/95568] " ppalka at gcc dot gnu.org
@ 2020-06-18 19:47 ` mpolacek at gcc dot gnu.org
2020-06-18 21:48 ` mpolacek at gcc dot gnu.org
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-06-18 19:47 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95568
Marek Polacek <mpolacek at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |mpolacek at gcc dot gnu.org
--- Comment #2 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
The problem seems to be not that we're in a require-clause but that we're in a
template, the following is also rejected:
template<class T> struct X { T x; };
template<class T> void g () { X{0}; }
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/95568] No CTAD with list initialization within requires-clause
2020-06-08 2:17 [Bug c++/95568] New: No CTAD with list initialization within requires-clause johelegp at gmail dot com
2020-06-16 19:51 ` [Bug c++/95568] " ppalka at gcc dot gnu.org
2020-06-18 19:47 ` mpolacek at gcc dot gnu.org
@ 2020-06-18 21:48 ` mpolacek at gcc dot gnu.org
2020-06-18 22:56 ` mpolacek at gcc dot gnu.org
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-06-18 21:48 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95568
Marek Polacek <mpolacek at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jason at gcc dot gnu.org
--- Comment #3 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
So far my guess is that this doesn't work because in a template
finish_decltype_type will create a DECLTYPE_TYPE in the deduction guide, so
we'll have
template<class T> X(decltype (X<T>::x))-> X<T>
deduction guide. type_unification_real then tries to deduce T from a P/A pair
decltype (X<T>::x) and 0. But:
The non-deduced contexts are:
-- The expression of a decltype-specifier.
and
If a template parameter is used only in non-deduced contexts and is not
explicitly specified, template argument deduction fails.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/95568] No CTAD with list initialization within requires-clause
2020-06-08 2:17 [Bug c++/95568] New: No CTAD with list initialization within requires-clause johelegp at gmail dot com
` (2 preceding siblings ...)
2020-06-18 21:48 ` mpolacek at gcc dot gnu.org
@ 2020-06-18 22:56 ` mpolacek at gcc dot gnu.org
2020-06-20 18:02 ` johelegp at gmail dot com
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-06-18 22:56 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95568
Marek Polacek <mpolacek at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |ASSIGNED
Assignee|unassigned at gcc dot gnu.org |mpolacek at gcc dot gnu.org
--- Comment #4 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
A patch I've been playing with
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -28767,7 +28767,11 @@ do_class_deduction (tree ptype, tree tmpl, tree init,
}
if (tree guide = maybe_aggr_guide (tmpl, init, args))
- cands = lookup_add (guide, cands);
+ {
+ if (dependent_type_p (TREE_TYPE (guide)))
+ return ptype;
+ cands = lookup_add (guide, cands);
+ }
tree call = error_mark_node;
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/95568] No CTAD with list initialization within requires-clause
2020-06-08 2:17 [Bug c++/95568] New: No CTAD with list initialization within requires-clause johelegp at gmail dot com
` (3 preceding siblings ...)
2020-06-18 22:56 ` mpolacek at gcc dot gnu.org
@ 2020-06-20 18:02 ` johelegp at gmail dot com
2020-06-29 15:00 ` [Bug c++/95568] No CTAD with list initialization within templated entity cvs-commit at gcc dot gnu.org
2020-06-29 15:12 ` mpolacek at gcc dot gnu.org
6 siblings, 0 replies; 8+ messages in thread
From: johelegp at gmail dot com @ 2020-06-20 18:02 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95568
--- Comment #5 from Johel Ernesto Guerrero Peña <johelegp at gmail dot com> ---
(In reply to Marek Polacek from comment #2)
> The problem seems to be not that we're in a require-clause but that we're in
> a template, the following is also rejected:
>
> template<class T> struct X { T x; };
> template<class T> void g () { X{0}; }
Then this may be related to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95434.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/95568] No CTAD with list initialization within templated entity
2020-06-08 2:17 [Bug c++/95568] New: No CTAD with list initialization within requires-clause johelegp at gmail dot com
` (4 preceding siblings ...)
2020-06-20 18:02 ` johelegp at gmail dot com
@ 2020-06-29 15:00 ` cvs-commit at gcc dot gnu.org
2020-06-29 15:12 ` mpolacek at gcc dot gnu.org
6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-06-29 15:00 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95568
--- Comment #6 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Marek Polacek <mpolacek@gcc.gnu.org>:
https://gcc.gnu.org/g:b1005f553d3543bb56dc6b9b34ee35455d697ca4
commit r11-1713-gb1005f553d3543bb56dc6b9b34ee35455d697ca4
Author: Marek Polacek <polacek@redhat.com>
Date: Tue Jun 23 18:07:34 2020 -0400
c++: Fix CTAD for aggregates in template [PR95568]
95568 complains that CTAD for aggregates doesn't work within
requires-clause and it turned out that it doesn't work when we try
the deduction in a template. The reason is that maybe_aggr_guide
creates a guide that can look like this
template<class T> X(decltype (X<T>::x))-> X<T>
where the parameter is a decltype, which is a non-deduced context. So
the subsequent build_new_function_call fails because unify_one_argument
can't deduce anything from it ([temp.deduct.type]: "If a template
parameter is used only in non-deduced contexts and is not explicitly
specified, template argument deduction fails.")
Those decltypes come from finish_decltype_type. We can just use
TREE_TYPE instead. I pondered using unlowered_expr_type, but that
didn't make any difference for the FIELD_DECLs I saw in
class-deduction-aggr6.C.
gcc/cp/ChangeLog:
PR c++/95568
* pt.c (collect_ctor_idx_types): Use TREE_TYPE.
gcc/testsuite/ChangeLog:
PR c++/95568
* g++.dg/cpp2a/class-deduction-aggr5.C: New test.
* g++.dg/cpp2a/class-deduction-aggr6.C: New test.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/95568] No CTAD with list initialization within templated entity
2020-06-08 2:17 [Bug c++/95568] New: No CTAD with list initialization within requires-clause johelegp at gmail dot com
` (5 preceding siblings ...)
2020-06-29 15:00 ` [Bug c++/95568] No CTAD with list initialization within templated entity cvs-commit at gcc dot gnu.org
@ 2020-06-29 15:12 ` mpolacek at gcc dot gnu.org
6 siblings, 0 replies; 8+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-06-29 15:12 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95568
Marek Polacek <mpolacek at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |FIXED
Status|ASSIGNED |RESOLVED
--- Comment #7 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Fixed.
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2020-06-29 15:12 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-08 2:17 [Bug c++/95568] New: No CTAD with list initialization within requires-clause johelegp at gmail dot com
2020-06-16 19:51 ` [Bug c++/95568] " ppalka at gcc dot gnu.org
2020-06-18 19:47 ` mpolacek at gcc dot gnu.org
2020-06-18 21:48 ` mpolacek at gcc dot gnu.org
2020-06-18 22:56 ` mpolacek at gcc dot gnu.org
2020-06-20 18:02 ` johelegp at gmail dot com
2020-06-29 15:00 ` [Bug c++/95568] No CTAD with list initialization within templated entity cvs-commit at gcc dot gnu.org
2020-06-29 15:12 ` mpolacek 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).