https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124676
Bug ID: 124676
Summary: Diagnostic on invalid overloading shows malformed
constraint
Product: gcc
Version: 16.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: ivan.lazaric.gcc at gmail dot com
Target Milestone: ---
```cpp
template<typename T>
consteval bool prereq() { return false; }
template<typename T>
struct S {
S operator&(S) requires(prereq<T>());
S& operator&(S) requires(prereq<T>());
};
```
Flags just "-std=c++26"
Compiler output:
```
<source>:7:8: error: 'S<T>& S<T>::operator&(S<T>) requires (prereq<T>)()'
cannot be overloaded with 'S<T> S<T>::operator&(S<T>) requires (prereq<T>)()'
[-Wtemplate-body]
7 | S& operator&(S) requires(prereq<T>());
| ^~~~~~~~
<source>:6:7: note: previous declaration 'S<T> S<T>::operator&(S<T>) requires
(prereq<T>)()'
6 | S operator&(S) requires(prereq<T>());
| ^~~~~~~~
Compiler returned: 1
```
It says "requires (prereq<T>)()" in first line, it probably should say instead
"requires (prereq<T>())"
Godbolt of example: https://godbolt.org/z/fsYz13PM4