https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93915
Bug ID: 93915
Summary: Suboptimal error message when there is no usable
postfix operator-- overload due to unsatisfied
constraints
Product: gcc
Version: 10.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: ppalka at gcc dot gnu.org
Target Milestone: ---
$ cat postfix.cc
template<typename T>
struct foo
{
void
operator--(int)
requires false
{
}
};
int
main()
{
foo<int> x;
x--;
}
$ g++ -std=c++2a postfix.cc
postfix.cc: In function ‘int main()’:
postfix.cc:15:4: error: no ‘operator--(int)’ declared for postfix ‘--’
[-fpermissive]
15 | x--;
| ~^~
The same test case with prefix operator-- gives the better error
postfix.cc: In function ‘int main()’:
postfix.cc:15:3: error: no match for ‘operator--’ (operand type is ‘foo<int>’)
15 | --x;
| ^~~
postfix.cc:5:3: note: candidate: ‘void foo<T>::operator--() requires false
[with T = int]’
5 | operator--()
| ^~~~~~~~
postfix.cc:5:3: note: constraints not satisfied
[...]