https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92089
Bug ID: 92089
Summary: [concepts] requires-expression results in hard error
during constraint checking
Product: gcc
Version: 10.0
Status: UNCONFIRMED
Keywords: diagnostic, rejects-valid
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: redi at gcc dot gnu.org
Target Milestone: ---
template<typename T>
concept anything = true;
template<typename> struct incrementable_traits { using type = int; };
template<typename T>
requires requires(T a, T b) { { a - b } -> anything; }
struct incrementable_traits<T>
{
};
incrementable_traits<void>::type t;
In file included from
/home/jwakely/gcc/10/include/c++/10.0.0/bits/stl_iterator_base_types.h:71,
from
/home/jwakely/gcc/10/include/c++/10.0.0/bits/stl_algobase.h:65,
from /home/jwakely/gcc/10/include/c++/10.0.0/array:40,
from iterc.cc:13:
/home/jwakely/gcc/10/include/c++/10.0.0/bits/iterator_concepts.h:139:14: error:
invalid use of 'void'
139 | { { a - b } -> integral; })
| ~~^~~
There are two problems here. Firstly, if it's an invalid use of void then the
requires-clause should simply fail to be satisfied, there should not be an
error.
Secondly, there's no context and no clue where the problem comes from. In the
real code I had 300 lines of code and was given no clue which one happened to
instantiate this constraint with type 'void'.
It might be helpful to say something like "during constraint checking for
incrementable_traits<void>" and then "required from ..." as we do for template
instantiations (or would that negate the supposed benefits of concepts for
clearer diagnostics?)