[Bug c++/85004] ambiguous diagnostic: passing ‘const S’ as ‘this’ argument discards qualifiers
redi at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Tue Mar 20 18:33:00 GMT 2018
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85004
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2018-03-20
See Also| |https://gcc.gnu.org/bugzill
| |a/show_bug.cgi?id=53281
Ever confirmed|0 |1
--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
As I said in PR 53281 comment 5, I think we should stop talking about "passing
'const S' as 'this' argument, because it's a leaky abstraction, and inaccurate
(this should be a pointer S* not S).
With the patch there it says:
u.C: In member function 'void S::g() const':
u.C:6:18: error: cannot call non-const member function on object of type 'const
S' [-fpermissive]
this->f (this); // which 'this?'
^
u.C:2:8: note: in call to 'void S::f(const S*)'
void f (const S*);
^
u.C:8:12: error: cannot call non-const member function on object of type 'const
S' [-fpermissive]
f (this); // ditto
^
u.C:2:8: note: in call to 'void S::f(const S*)'
void f (const S*);
^
More information about the Gcc-bugs
mailing list