[Bug c++/97407] New: Expanding alias template in concept satisfaction error is undesirable
redi at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Tue Oct 13 19:04:13 GMT 2020
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97407
Bug ID: 97407
Summary: Expanding alias template in concept satisfaction error
is undesirable
Product: gcc
Version: 10.2.1
Status: UNCONFIRMED
Keywords: diagnostic
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: redi at gcc dot gnu.org
Target Milestone: ---
Compiling this with -std=c++20:
#include <ranges>
template<typename T> concept False = false;
template<typename R>
requires False<std::ranges::iterator_t<R>>
void f(R&)
{ }
int main()
{
int a[2];
f(a);
}
Produces the expected error:
alias.C: In function ‘int main()’:
alias.C:13:6: error: use of function ‘void f(R&) [with R = int [2]]’ with
unsatisfied constraints
alias.C:7:6: note: declared here
alias.C:7:6: note: constraints not satisfied
alias.C: In instantiation of ‘void f(R&) [with R = int [2]]’:
alias.C:13:6: required from here
alias.C:3:30: required for the satisfaction of ‘False<decltype
(std::__detail::__ranges_begin(declval<_Container&>()))>’ [with _Container =
int[2]]
alias.C:3:38: note: the expression ‘false’ evaluated to ‘false’
However the second to last line refers to
std::__detail::__ranges_begin(declval<_Container&>()))
This is meaningless to users, and "_Container" is not used in the definitions
of ranges::iterator_t or anything it uses. The compiler seems drunk and is
remembering the template argument of a different, unrelated use of the same
alias template. That's probably PR 95310.
I think it would be better to leave that alias unexpanded, as
std::ranges::iterator_t<R>.
More information about the Gcc-bugs
mailing list