Consider the following c++ program:
class A
{
protected:
int x;
};
template<typename X>
using B = A;
template<typename T>
class C : public B<T>
{
public:
void f()
{
x = 0;
}
};
int main()
{
}
When compiled with clang and gcc using -std=c++17 -pedantic-errors
as compilation options they behave differently: Clang compiles without any errors, but gcc gives a compilation error about not being able to lookup the identifier x
.
What does the c++ standard say in this case? Are both behaviours allowed, or does one of the compilers have a bug in this case?
Compiler explorer link: https://godbolt.org/z/EYvYrr