http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54235

             Bug #: 54235
           Summary: Templates compile but don't link
    Classification: Unclassified
           Product: gcc
           Version: 4.6.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassig...@gcc.gnu.org
        ReportedBy: todor.mi...@gmail.com


//This compiles but does not link on gcc 4.6.3, ubuntu 32 bit.
//Discussed at: http://www.cplusplus.com/forum/general/77046/#msg414427
//Compiles and links on other compilers/platforms.
//The code is a minified version from a real project.
//main.cpp
class Integer
{
public:
  static unsigned int HashFunction(const Integer& input)
  { return 0;
  }
};

template <class Object, unsigned int hashFunction(const
Object&)=Object::HashFunction>
class List
{
public:
  inline unsigned int GetHash(const Object& input)const
  { return hashFunction(input);
  }
};

template <class Object>
class ListSpecialized: public List<Object, Object::HashFunction>
{
};

template <class CoefficientType, unsigned int inputHashFunction(const
CoefficientType&)= CoefficientType::HashFunction>
class Element
{
public:
  static inline unsigned int HashFunction(const Element<CoefficientType,
inputHashFunction>& input)
  { CoefficientType x;
    return inputHashFunction(x);
  }
};

template<class CoefficientType>
class TheComputation
{
public:
  List<Element<Integer>, Element<Integer>::HashFunction >
  //ListSpecialized<Element<Integer> >
  theList;
};

int main()
{ TheComputation<Integer > A;
  Element<Integer> x;
  A.theList.GetHash(x);
  return 0;
}

Reply via email to