The assertion in the following program gives different results according to the compiler used: in GCC 4.4 the assertions fails, while in CLang does not. It looks like GCC does not like V being private in C. Is this a bug?
#include <cassert>
class V {
public:
virtual ~V() { };
};
template<class T>
class C : public T, private V {
public:
static V* new_() {
return new C();
}
};
struct MyT {
};
typedef C<MyT> C_MyT;
int main(int argc, char** argv) {
V* o2 = C_MyT::new_();
assert(dynamic_cast<C_MyT*> (o2)); // failure in GCC, success in CLang
return 0;
}