Consider this program:
#include <iostream>
using std::cout;
using std::endl;
struct C {
int x;
C(int _x) : x(_x) {}
operator bool() const { return 0 != x; }
};
struct D {
float f;
D(float _f) : f(_f) {}
operator bool() const { return 0.0f != f; }
};
int main() {
C c(9);
D d(2.0f);
if (c == d) {
cout << "Equal" << endl;
}
return 0;
}
g++ 3.4.4 doesn't so much as warn that something is fishy here, even with -Wall.Not only that, but c and d are considered to be equal.