[Bug c++/95568] No CTAD with list initialization within requires-clause

2020-06-20 Thread johelegp at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95568

--- Comment #5 from Johel Ernesto Guerrero Peña  ---
(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 struct X { T x; };
> template void g () { X{0}; }

Then this may be related to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95434.

[Bug c++/95568] No CTAD with list initialization within requires-clause

2020-06-18 Thread mpolacek at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95568

Marek Polacek  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  ---
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;

[Bug c++/95568] No CTAD with list initialization within requires-clause

2020-06-18 Thread mpolacek at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95568

Marek Polacek  changed:

   What|Removed |Added

 CC||jason at gcc dot gnu.org

--- Comment #3 from Marek Polacek  ---
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 X(decltype (X::x))-> X

deduction guide.  type_unification_real then tries to deduce T from a P/A pair
decltype (X::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.

[Bug c++/95568] No CTAD with list initialization within requires-clause

2020-06-18 Thread mpolacek at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95568

Marek Polacek  changed:

   What|Removed |Added

 CC||mpolacek at gcc dot gnu.org

--- Comment #2 from Marek Polacek  ---
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 struct X { T x; };
template void g () { X{0}; }

[Bug c++/95568] No CTAD with list initialization within requires-clause

2020-06-16 Thread ppalka at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95568

Patrick Palka  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  ---
Confirmed.