This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/49329] New: Static method with std::string parameter gets messed up with non-static method with bool parameter


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]