https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122531
--- Comment #5 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Clang's output for the same code is:
aka.cc:5:7: error: no viable overloaded '='
5 | a = "oops";
| ~ ^ ~~~~~~
/usr/bin/../lib/gcc/x86_64-redhat-linux/15/../../../../include/c++/15/bits/basic_string.h:904:7:
note: candidate function not viable: 'this' argument has type 'const
std::string' (aka 'const basic_string<char>'), but method is not marked const
904 | operator=(const basic_string& __str)
| ^
/usr/bin/../lib/gcc/x86_64-redhat-linux/15/../../../../include/c++/15/bits/basic_string.h:915:7:
note: candidate function not viable: 'this' argument has type 'const
std::string' (aka 'const basic_string<char>'), but method is not marked const
915 | operator=(const _CharT* __s)
| ^
/usr/bin/../lib/gcc/x86_64-redhat-linux/15/../../../../include/c++/15/bits/basic_string.h:927:7:
note: candidate function not viable: 'this' argument has type 'const
std::string' (aka 'const basic_string<char>'), but method is not marked const
927 | operator=(_CharT __c)
| ^
/usr/bin/../lib/gcc/x86_64-redhat-linux/15/../../../../include/c++/15/bits/basic_string.h:945:7:
note: candidate function not viable: 'this' argument has type 'const
std::string' (aka 'const basic_string<char>'), but method is not marked const
945 | operator=(basic_string&& __str)
| ^
/usr/bin/../lib/gcc/x86_64-redhat-linux/15/../../../../include/c++/15/bits/basic_string.h:1013:7:
note: candidate function not viable: 'this' argument has type 'const
std::string' (aka 'const basic_string<char>'), but method is not marked const
1013 | operator=(initializer_list<_CharT> __l)
| ^
/usr/bin/../lib/gcc/x86_64-redhat-linux/15/../../../../include/c++/15/bits/basic_string.h:1028:8:
note: candidate function template not viable: 'this' argument has type 'const
std::string' (aka 'const basic_string<char>'), but method is not marked const
1028 | operator=(const _Tp& __svt)
| ^
1 error generated.
This just omits all information about the overload candidates, *only* telling
you where it's declared and why it's not viable (which is worded much better
than GCC's "discards qualifiers", see Bug 53281 for an improvement I
suggested). Clang relies almost entirely on the code snippets to give you the
context of what each candidate is.