This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/53281] poor error message for calling a non-const method from a const object
- From: "rui.maciel at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 08 May 2012 13:27:24 +0000
- Subject: [Bug c++/53281] poor error message for calling a non-const method from a const object
- Auto-submitted: auto-generated
- References: <bug-53281-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53281
--- Comment #1 from Rui Maciel <rui.maciel at gmail dot com> 2012-05-08 13:27:24 UTC ---
The same suggestion applies to the cases where a non-const method is called
from a const method, such as in the example below:
<code>
class Foo {
void bar1() {}
void bar2() const {
bar1();
}
};
int main()
{
return 0;
}
</code>
The same error message is returned:
<message>
main.c++: In member function âvoid Foo::bar2() constâ:
main.c++:4:22: error: passing âconst Fooâ as âthisâ argument of âvoid
Foo::bar1()â discards qualifiers [-fpermissive]
</message>