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

--- Comment #6 from Jonny Grant <jg at jguk dot org> ---
(In reply to Andrew Pinski from comment #1)
> Confirmed.
> Maybe just a small improvement to the original warning message is needed
> here about the qualifier
> 
> That is:
> <source>:12:14: error: no match for 'operator=' (operand types are 'const
> std::string' {aka 'const std::__cxx11::basic_string<char>'} and
> 'std::string' {aka 'std::__cxx11::basic_string<char>'})
>    12 |     test.a = oops;
>       |              ^~~~
> 
> Could be improved to:
> ```
> <source>:12:14: error: no match for 'operator=' (Hint: type of lhs is
> const-qualified) (operand types are 'const std::string' {aka 'const
> std::__cxx11::basic_string<char>'} and 'std::string' {aka
> 'std::__cxx11::basic_string<char>'})
>    12 |     test.a = oops;
>       |              ^~~~
> ```


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=



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'

Reply via email to