g++ 4.0.3 as well as g++-3.4 fails to compile the attached program b.cpp with the following errors:
b.cpp:12: error: declaration of 'operator-' as non-function b.cpp:12: error: expected ';' before '<' token Things become even worse if we make int x; private in class A (see b2.cpp). g++ 4.0.3 starts complaining: b2.cpp:12: error: declaration of 'operator-' as non-function b2.cpp:12: error: expected ';' before '<' token b2.cpp: In function 'A<n> operator-(const A<n>&, const A<n>&) [with int n = 0]': b2.cpp:18: instantiated from here b2.cpp:7: error: 'int A<0>::x' is private b2.cpp:23: error: within this context b2.cpp:7: error: 'int A<0>::x' is private b2.cpp:23: error: within this context b2.cpp:7: error: 'int A<0>::x' is private b2.cpp:23: error: within this context g++ 3.3 compiles both b.cpp and b2.cpp without a single warning. So I believe this is a regression. -- Summary: g++ messes up member operator with friend operator in spite of having arguments of different types Product: gcc Version: 4.0.3 Status: UNCONFIRMED Severity: major Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: relf at os2 dot ru http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25867