[cfe-dev] clang fails to build templated C++ code that other compilers can

Michael Jackson mike.jackson at bluequartz.net
Wed Jul 28 07:51:53 PDT 2010


That is absolutely AWESOME... Rebuilding Clang now.. then we can see  
how far we get with VTK...
___________________________________________________________
Mike Jackson                      www.bluequartz.net
Principal Software Engineer       mike.jackson at bluequartz.net
BlueQuartz Software               Dayton, Ohio



On Jul 28, 2010, at 10:50 AM, Douglas Gregor wrote:

>
> 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