[cfe-dev] clang fails to build templated C++ code that other compilers can
Douglas Gregor
dgregor at apple.com
Wed Jul 28 07:50:35 PDT 2010
On Jul 27, 2010, at 8:25 AM, Sean McBride wrote:
> 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? :)
This was a Clang bug (PR7725). It's fixed as of r109582. Thanks for the bug report!
- Doug
More information about the cfe-dev
mailing list