Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 368404

Summary: Error involving template partial specializations for pointers
Product: [Tools] CDT Reporter: Nathan Ridge <zeratul976>
Component: cdt-indexerAssignee: Markus Schorn <mschorn.eclipse>
Status: RESOLVED FIXED QA Contact: Markus Schorn <mschorn.eclipse>
Severity: normal    
Priority: P3 CC: cdtdoug
Version: 8.1.0   
Target Milestone: 8.1.0   
Hardware: All   
OS: All   
Whiteboard:

Description Nathan Ridge CLA 2012-01-11 22:36:44 EST
test.hpp:

template <typename T> 
struct remove_const_impl {};

template <typename T>
struct remove_const_impl<T*>
{
    typedef T type;
};

template <typename T>
struct remove_const_impl<const T*>
{
    typedef T type;
};

template <typename T>
struct remove_const
{
    typedef typename remove_const_impl<T*>::type type;
};


test.cpp:

#include "test.hpp"

template<typename Seq>
struct foo;

template <>
struct foo<int>
{
    typedef int type;
};

typedef foo<remove_const<const int>::type>::type t;  // ERROR HERE


The error at the indicated line is: "Type 'foo<remove_const<const int>::type>::type' could not be resolved"

The error goes away in the following cases:
  - contents of test.hpp are pasted into test.cpp
  - test.cpp calls remove_const<int> instead of remove_const<const int>
  - test.cpp calls remove_const_impl directly instead of through the remove_const wrapper
  - remove_const_impl is modified to specialize on T and const T, rather than T* and const T*
Comment 1 Markus Schorn CLA 2012-01-13 09:06:09 EST
Added testcase and fix.
Comment 2 CDT Genie CLA 2012-02-29 13:21:16 EST
*** cdt git genie on behalf of Markus Schorn ***

    Bug 368404: Current instantiation of class template partial specializations.

[*] http://git.eclipse.org/c/cdt/org.eclipse.cdt.git/commit/?id=1467a456bd822e30ce023b723bf21aecb98798db
Comment 3 CDT Genie CLA 2012-02-29 13:21:18 EST
*** cdt git genie on behalf of Markus Schorn ***

    Bug 368404: Testcase.

[*] http://git.eclipse.org/c/cdt/org.eclipse.cdt.git/commit/?id=59c4d10629cf7e8567ffb9759022212654c58615