> > I'm having trouble with the following piece of c++ code. Is this a bug > in gcc or am I doing something wrong? The code compiles and runs > without problems in icc. > > GCC Version: 3.3.2 > > struct doubler { > double operator*(double val) { > return 2.0 * val; > } > }; > > template<typename T> T operator*(double lhs , T rhs) { > return rhs * lhs; > } > > int main() { > doubler a; > a * 3.0; > return 0; > } > > Compiling this gives the following error message. > > test3.cc: In function `T operator*(double, T)': > test3.cc:7: error: `T operator*(double, T) [with T = double]' must have > an > argument of class or enumerated type > > Thanks. > I can't find no fault with this code: When overload resolution happens (section 13.3 of the Standard), then according to clause 13.3.1.2 the set of member candidates for operator * consists of doubler::operator *(double), while the set of non-member candidates is empty. So overload resolution should unambiguously choose the member operator of class doubler. Instead, gcc seems to ignore the member operator, and considers as only candidate the operator template, resulting in a failing overload resolution. To me g++ seems to be wrong. Oliver