http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53281
Bug #: 53281 Summary: poor error message for calling a non-const method from a const object Classification: Unclassified Product: gcc Version: 4.6.3 Status: UNCONFIRMED Severity: enhancement Priority: P3 Component: c++ AssignedTo: unassig...@gcc.gnu.org ReportedBy: rui.mac...@gmail.com Consider the following code: <code> class Foo { void bar1() {} void bar2(Foo const &foo) { foo.bar1(); } }; int main() { return 0; } </code> When this code is compiled with g++, the following error message is shown: <message> main.c++: In member function ‘const void Foo::bar2(const Foo&)’: main.c++:4:26: error: passing ‘const Foo’ as ‘this’ argument of ‘const void Foo::bar1()’ discards qualifiers [-fpermissive] </message> The error message is technically correct. Yet, it is too cryptic and a bit unhelpful, to the point it may be considered that the point of this error message is entirely missed. As an alternative, it would be nice if g++ displayed an error message which would actually be straight-forward and provided a clear description of the problem at hand, such as "trying to call a non-const method from a const object".