https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122259

--- Comment #9 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Jonny Grant from comment #6)
> Where it says "no match for 'operator='" given there can never be a valid
> operator= for a const object - can the text be clear on that point? could
> just directly state can't assign to a const object. Otherwise programmer
> reading will be first considering if there should be an operator=

The fact it shows you half a dozen non-matching overloads of operator= should
make it pretty obvious that the problem isn't whether there should be an
operator=. Clearly there are several of them.

But Harald's suggestion seems worth exploring. Simply adding a note after the
first error (and before the list of non-matching candidates) might help:

note: no overload of 'operator=' allows assignment to 'const std::string'


> Is it possible to just say in that Hint 'const' instead of 'const-qualified'
> I know that is just terminological, it would simplify the output. We we talk
> with programmers we just say 'const', we don't say 'const-qualified'

But "type is const" is not correct, the type is something like "const T".

const is a qualifier, not a type, and plenty of programmers know that. Clarity
is important, but so is correctness. Striking a balance can be hard.

Reply via email to