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: [email protected]
ReportedBy: [email protected]
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.