-
Notifications
You must be signed in to change notification settings - Fork 15.3k
Closed
Labels
c++20clang:frontendLanguage frontend issues, e.g. anything involving "Sema"Language frontend issues, e.g. anything involving "Sema"conceptsC++20 conceptsC++20 conceptsconfirmedVerified by a second partyVerified by a second party
Description
Consider the following code:
struct s{
template<class T>
int operator+(const T&)const{return 0;}
};
template<class T>
concept AlwaysTrue=true;
template<AlwaysTrue T>
int operator+(const s&,const T&){return 1;}
int main(){
return s{}+1;
}
godbolt example: https://godbolt.org/z/vG31vjxbn
Since the 2nd operator+ is more constrained clang should choose that. However clang reports an ambiguity. (GCC chooses the 2nd one as expected)
Note that the ambiguity remains if the only 1st, or both declaration have a concept, (even if one of them is more constrained).
If we define both operators inside the class or both operators outside the class clang chooses the correct overload.
Metadata
Metadata
Assignees
Labels
c++20clang:frontendLanguage frontend issues, e.g. anything involving "Sema"Language frontend issues, e.g. anything involving "Sema"conceptsC++20 conceptsC++20 conceptsconfirmedVerified by a second partyVerified by a second party
Type
Projects
Status
Done