on-internet
← Community

GCC accepts defauling already declared comparison operator while Clang rejects

Stack Overflow ·

Consider the following program that is accepted by gcc and msvc but rejected by clang and edg: Demo struct A; bool operator==(A, A); struct A { friend bool operator==(A, A) = default; //gcc and msvc OK while clang and edg NO }; int main() { A a,b; int i = a==b; } I want to know if this program is well-formed or not and what exactly does the C++23 standard say about this program. Clang says: <source>:4:17: error: defaulting this equality comparison operator is not allowed because it was already declared outside the class 4 | friend bool operator==(A, A) = default; //gcc and msvc OK while clang

Comments

Sign in or sign up to comment and upvote.

No comments yet.