A bug in gcc 2.95, perhaps?

Martin v. Loewis martin@mira.isdn.cs.tu-berlin.de
Sun Oct 31 23:03:00 GMT 1999

> It could be related to 2.95 being more strick.  But in this case I
> think 2.95 is in error, or at least unnecessarily strict.  Without
> type conversion by single argument constructors the programmer is
> faced with having to code many permutations of operatorX() member
> functions.

Thanks for your bug report. The compiler conforms to the ISO C++
standard in this respect. As a result, it indeed does not operate the
same way as gcc 2.7, and, in that sense, it is more strict. Since this
is mandated by the standard, it is not "unnecessarily strict".

To find out what 'a == 1' means, the compiler first has to find all
"candidate" operators. There is a number of builtin operators (which
are not interesting here), and

  template<class T> const char operator==(const bug<T>&, const bug<T>&);

To see whether this template is useful, "template argument deduction"
must be performed. To do that, the actual argument types are compared
with formal parameter types. In that case, deduction fails: T would be
"int", but that does not fit with the second argument.

Since the template is not a candidate, it does not participate in
overload resolution. If that template was used in overload resolution,
it would be called (using the bug(int) constructor) - but that does
not happen.

If you think this is not the way how C++ is defined, or should be
defined, please discuss that in comp.lang.c++.moderated.

Hope this helps,

More information about the Gcc-bugs mailing list