M
montyshasta
Take this code as a base case, it compiles successfully:
struct R
{
int i;
};
class S : public R
{
void F(void) {i = 0;}
};
S s;
Switch to deriving S from R as a template argument and the behavior
varies by compiler:
struct R
{
int i;
};
template <class T>
class S : public T
{
void F(void) {i = 0;}
};
S<R> s;
Visual Studio succeeds building this. GCC fails with "error: 'i'
was not declared in this scope". ICC (Intel's compiler) succeeds with
that instantiation but fails if you attempt an explicit template
instantiation, like:
template class S<R>;
GCC and ICC succeed if you switch to a qualified reference to i:
void F(void) {T::i = 0;}
Is the way namespaces are inherited from base classes supposed to work
differently if those base classes are template arguments or is
something wrong with the compilers?
struct R
{
int i;
};
class S : public R
{
void F(void) {i = 0;}
};
S s;
Switch to deriving S from R as a template argument and the behavior
varies by compiler:
struct R
{
int i;
};
template <class T>
class S : public T
{
void F(void) {i = 0;}
};
S<R> s;
Visual Studio succeeds building this. GCC fails with "error: 'i'
was not declared in this scope". ICC (Intel's compiler) succeeds with
that instantiation but fails if you attempt an explicit template
instantiation, like:
template class S<R>;
GCC and ICC succeed if you switch to a qualified reference to i:
void F(void) {T::i = 0;}
Is the way namespaces are inherited from base classes supposed to work
differently if those base classes are template arguments or is
something wrong with the compilers?