compiler template declaration/definition mismatch error - by Mumau

Status : 

  Fixed<br /><br />
		This item has been fixed in the current or upcoming version of this product.<br /><br />
		A more detailed explanation for the resolution of this particular item may have been provided in the comments section.


2
0
Sign in
to vote
ID 640228 Comments
Status Closed Workarounds
Type Bug Repros 0
Opened 1/29/2011 7:54:41 AM
Access Restriction Public

Description

The compiler is generating an invalid error (2244) while compiling the code listed below in steps to reproduce.  I have consolidated the code that is causing the error into a concise example for demonstration purposes.  The compiler is not able to correctly match the class method definition to the class method declaration.

I do have a work around that is not ideal.
Sign in to post a comment.
Posted by Microsoft on 3/8/2011 at 9:41 AM
Hi Mumau:
    A fix for this issue has been checked into the compiler sources. The fix should show up in the next release of Visual C++.

Xiang Fan
Visual C++ Team
Posted by Microsoft on 3/1/2011 at 6:20 PM
Hello,

Thank you for reporting this bug. This is indeed our compiler bug for out of line definition of template function with template template parameter list. Some notes in the code below. We will continue investigating this bug and will fix it in a future release.

Thanks,
Ulzii Luvsanbat
Windows C++ Team

template<typename T>
class Compare
{
public:
    bool operator () (T const& left, T const& right) const
    {
        return left < right;
    }
};

template<typename T>
class Node
{
public:
};

template<typename T>
class TreeCore
{
public:
};

template<typename T,
    typename Comp_t = Compare<T>,
    template<typename> class Core_t = TreeCore>
class Tree
{
public:
    typedef Node<T> Node_t;
};

template<typename T>
class TestData
{
public:
};

template<template<typename X1, typename X2, template<typename X3> class> class Tree_t,
         template<typename X4> class Core_t>
class TreeBaseTest
{
public:
    // the compiler does not complain about this method
    template<typename T, typename Comp1_t, typename Comp2_t>
    int verifyContents (Tree_t<T, Comp1_t, Core_t> const& tree, Comp2_t const& comp, TestData<T> const* const pData, size_t count) const;


    // the compiler does not match this decalaration with the definition
    template<typename T, typename BUG>
    int verifyBalance ( typename Tree_t<T, BUG /* HERE!!! It's using wrong template parameter */, Core_t>::Node_t const* pNode, int* pHeightOut) const;

};

template<template<typename, typename, template<typename> class> class Tree_t,
         template<typename> class Core_t>
template<typename T, typename Comp1_t, typename Comp2_t>
int TreeBaseTest<Tree_t, Core_t>::verifyContents ( Tree_t<T, Comp1_t, Core_t> const& tree, Comp2_t const& comp, TestData<T> const* const pData, size_t count) const
{
    return 0;
}


// the compiler does not match this definition with the declaration
template<template<typename X1, typename X2, template<typename X3> class> class Tree_t,
         template<typename X4> class Core_t>
template<typename T, typename Comp_t>
int TreeBaseTest<Tree_t, Core_t>::verifyBalance ( typename Tree_t<T, Comp_t, Core_t>::Node_t const* pNode, int* pHeightOut) const
{
    return 0;
}


int main ()
{
    TreeBaseTest<Tree, TreeCore> treeBaseTest;
    Tree<int> tree;
    TestData<int> testData[1];
    Tree<int>::Node_t node;
    int height;

#if (0)
    // this won't compile due to previous errors
    treeBaseTest.verifyBalance<T, Compare<T> > (&node, &height);
#endif

    return treeBaseTest.verifyContents (tree, Compare<int> (), testData, 0);
}
Posted by Microsoft on 1/30/2011 at 7:12 PM
Thanks for your feedback.

We are rerouting this issue to the appropriate group within the Visual Studio Product Team for triage and resolution. These specialized experts will follow-up with your issue.
Posted by Microsoft on 1/29/2011 at 8:13 AM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(http://support.microsoft.com)