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

--- Comment #8 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to David Malcolm from comment #6)
> It seems best to special-case the "const member fn/param called with
> non-const" cases and to report them directly in terms of the types in user's
> source with and without "const", and to be explicit about which qualifier(s)
> are lost.

Don't forget 'volatile', which is rarely used for member function qualifiers,
but we might as well handle both at once (as my patches above do).


> Proposed output for the case in comment #3:
> 
> cv.cc: In member function ‘void Foo::bar2(const Foo&)’:
> cv.cc:4:26: error: passing ‘const Foo’ as ‘this’ argument discards 'const'
> qualifier [-fpermissive]
>                  foo.bar1();
>                           ^
> cv.cc:2:14: note:   in call to ‘void Foo::bar1()’ which is non-const
>          void bar1() {}
>               ^~~~

This has a number of problems, see comment 5 for discussion and a patch.

Reply via email to