clang fails to build templated C++ code that other compilers can

Hello,

We are trying to get VTK, an open source project, to build with clang
(trunk 109432). It builds with many other compilers on many platforms.
We have one problem down to the following:

#include <iostream>

class vtkArray
{
public:
  void PrintSelf(std::ostream &os) {
    std::cout << "vtkArray PrintSelf" << std::endl;
  }
};

template<class ThisT, class BaseT>
class vtkTypeTemplate : public BaseT
{
public:
  typedef BaseT Superclass;
};

template<typename T>
class vtkTypedArray : public vtkTypeTemplate<vtkTypedArray<T>, vtkArray>
{
public:
  void PrintSelf(std::ostream &os);
};

template<typename T>
void vtkTypedArray<T>::PrintSelf(std::ostream &os)
{
  this->vtkTypedArray<T>::Superclass::PrintSelf(os); // ERROR
}

int main (int argc, char const *argv)
{
  vtkTypedArray<int> array;
  array.PrintSelf(std::cout);
  return 0;
}

Which gives:

test.cp:28:27: error: no member named 'Superclass' in 'vtkTypedArray<T>'
  this->vtkTypedArray<T>::Superclass::PrintSelf(os);
        ~~~~~~~~~~~~~~~~~~^

I'm not enough of a C++ expert to know if clang is in error or just more
strict in some way. Any language lawyers here? :slight_smile:

Thanks,

test.cp (692 Bytes)

This was a Clang bug (PR7725). It's fixed as of r109582. Thanks for the bug report!

  - Doug

That is absolutely AWESOME... Rebuilding Clang now.. then we can see how far we get with VTK...