[Bug c++/92268] Constraint normalization substitutes parameter too early

2019-10-29 Thread jason at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92268

Jason Merrill  changed:

   What|Removed |Added

 CC||jason at gcc dot gnu.org

--- Comment #4 from Jason Merrill  ---
Smaller example:

template  concept Two = true;
template  concept One = Two;
template  concept Zero = requires
  {
   { T() } -> One;
  };

template 
void f() requires Zero;
template 
void f(...);

int main()
{
  f();
}

[Bug c++/92268] Constraint normalization substitutes parameter too early

2019-10-29 Thread andrew.n.sutton at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92268

Andrew Sutton  changed:

   What|Removed |Added

 CC||andrew.n.sutton at gmail dot 
com

--- Comment #3 from Andrew Sutton  ---
> [02:40]  but it looks like when we normalize the forward_iterator 
> constraint on the compound-requirement we're normalizing 
> forward_iterator, which is wrong -- we should be normalizing 
> forward_iterator, and then checking whether that's satisfied with iterator

> [02:40]  Andrew sent me a patch to improve handling of nested 
> requirements that I haven't looked at yet, it may help with this

This patch doesn't touch that. We're definitely not normalizing that constraint
at the point it appears. It's normalized w.r.t., substituted arguments in
do_auto_deduction.

I suppose the right thing to do is deduction vs. an unconstrained type, then
satisfaction vs. result.

[Bug c++/92268] Constraint normalization substitutes parameter too early

2019-10-29 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92268

--- Comment #2 from Jonathan Wakely  ---
(Comment 1 was wrong)

A workaround is to replace the compound-requirement with a simple-requirement
that depends on a function constrained with the desired constraint:


template void workaround(I) { }

template
concept F = requires (T& t) { workaround(t.begin()); };

[Bug c++/92268] Constraint normalization substitutes parameter too early

2019-10-29 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92268

--- Comment #1 from Jonathan Wakely  ---
The workaround is to require that the common_reference_t types exist:

template
  concept common_reference_with
=  
// 
   requires { typename common_reference_t;
  typename common_reference_t; }
   &&
// 
foo, common_reference_t>
&& bar, common_reference_t>
&& baz, common_reference_t>;

[Bug c++/92268] Constraint normalization substitutes parameter too early

2019-10-29 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92268

Jonathan Wakely  changed:

   What|Removed |Added

 Status|UNCONFIRMED |NEW
   Last reconfirmed||2019-10-29
 Ever confirmed|0   |1