Andrew

Compilers Archives

C++ Templates and Class Inheritance

Posted on May 17, 2007 1:03 AM

The following code is not legal C++:

template < class type >
struct A {
	void f() {}
	type mX;
};

template < class type >
struct B : public A<type> {
	void g() { mY = ( mX ); f(); }
	type mY;
};

The best part is that unless you know the obscure reason why it is not legal, it appears legal and might even compile and run perfectly depending on which compiler you're using. Not surprisingly, that is exactly how I ran in to it. I was doing templated class inheritance and thought I was in the clear because everything ran fine with MSVC7.1 and ICC 9, but when I belatedly tried to compile with g++ 3.4.4, I ran in to the following errors.. read more

MSVC rolls over

Posted on March 22, 2007 12:44 AM

If you are using MSVC7 or earlier and you want to rotate some uints, you'll be unpleasantly surprised when.. read more