Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 368311 - 'auto' type deduction failure involving templates
Summary: 'auto' type deduction failure involving templates
Status: RESOLVED FIXED
Alias: None
Product: CDT
Classification: Tools
Component: cdt-parser (show other bugs)
Version: 8.1.0   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 8.1.0   Edit
Assignee: Markus Schorn CLA
QA Contact: Markus Schorn CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-01-10 22:40 EST by Nathan Ridge CLA
Modified: 2012-02-29 13:21 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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