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

Bug 368311

Summary: 'auto' type deduction failure involving templates
Product: [Tools] CDT Reporter: Nathan Ridge <zeratul976>
Component: cdt-parserAssignee: 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-10 22:40:45 EST
In the following code:


template <class Value>
struct iterator
{
    Value operator*();
};

template <typename Iterator>
struct range
{
    Iterator begin();
};

template <typename T>
struct A
{
    struct iterator_t : public iterator<T> {};

    typedef range<iterator_t> range_t; 
};

struct S
{
    int x;
};

int main()
{
    A<S>::range_t r;
    auto cur = r.begin();
    auto e = *cur;
    e.x;            // ERROR HERE: "Field 'x' could not be resolved"
}


Something goes wrong in the two 'auto' type deductions in main(), and as a result CDT doesn't seem to know that the type of 'e' is 'S'.

Interestingly, if I change the first line in main() to:

range<A<S>::iterator_t> r;

(which is the same type, just referred to in a different way), it works!
Comment 1 Markus Schorn CLA 2012-01-12 05:37:04 EST
As always, nice example!
Added testcase and fix.
Comment 2 CDT Genie CLA 2012-02-29 13:21:13 EST
*** cdt git genie on behalf of Markus Schorn ***

    Bug 368311: Specialization of nested class used as argument for class instance.

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