From Bugzilla Helper: User-Agent: Mozilla/4.77 [en] (X11; U; Linux 2.4.2-2 i686) Description of problem: The following program compiles without a warning: class foo { public: int sum(int x, int x); // shouldn't it give an error here? }; //int foo::sum(int x, int x) // it does here int foo::sum(int x, int y) { return x + y; } How reproducible: Always Steps to Reproduce: 1. g++ -c -g -Wall foo.cpp Actual Results: g++ compiles the code without any warning. Expected Results: I'd expect g++ to give me an error. At least a warning. Additional info: rpm -q gcc gcc-2.96-81
Consider this: struct bar { int sum(int, int); // Any reason to give an error/warning here? };
I agree this should be diagnosed. Pushed upstream so that C++ language lawyers can have a go at it. Probably won't be fixed until gcc 4.1 though. http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17786