This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/49329] New: Static method with std::string parameter gets messed up with non-static method with bool parameter
- From: "swante2 at web dot de" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 8 Jun 2011 20:13:38 +0000
- Subject: [Bug c++/49329] New: Static method with std::string parameter gets messed up with non-static method with bool parameter
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49329
Summary: Static method with std::string parameter gets messed
up with non-static method with bool parameter
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: swante2@web.de
I want a static and a non-static method with the same name in a class like
this:
//main.cpp
#include <string>
class cc {
public:
void xx (bool b) {return;}
static void xx (std::string str) {return;}
};
int main(int argc, char **argv) {
cc instance;
instance.xx(true);
cc::xx("test string"); //error: cannot call member function
//'void cc::xx(bool)' without object
return 0;
}
When compiled with: g++ -o test main.cpp
I get the following error:
error: cannot call member function 'void cc::xx(bool)' without object
The error vanishes when I change the name of the non-static method, or
when I explicitly convert the char*-"test string" into a std::string, or when I
change the bool-parameter of the non-static method to an int-parameter;
But it's still a nasty, strange bug.
I'm using gcc 4.5.2 on ubuntu 11.04.