This code compiles with MSVC 2015, but doesn't compile with Clang 5.0.0 (trunk 304874):
template <typename T>
struct Base
{
T data;
};
template <typename T>
struct Derived : Base<T>
{
auto getData() const
{
return data;
}
};
Replacing data
with this->data
in Derived::getdata()
makes Clang happy.
Which compiler is correct according to the C++ standard?
Must this->
be used in template code to access an identifier of a base class?
data
is a dependent name. – Hedley/permissive-
switch emits the error "C2065: 'data': undeclared identifier" for this code. – Intelligencer