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

Bug 337688

Summary: Bogus errors when using a function as a template parameter
Product: [Tools] CDT Reporter: Nathan Ridge <zeratul976>
Component: cdt-indexerAssignee: Project Inbox <cdt-indexer-inbox>
Status: CLOSED DUPLICATE QA Contact: Markus Schorn <mschorn.eclipse>
Severity: normal    
Priority: P3 CC: cdtdoug
Version: 8.0   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:

Description Nathan Ridge CLA 2011-02-21 03:38:37 EST
For the following code:

struct A
{
    int x;
};

struct B
{
    A f(int);
};

template <typename Functor>
void g(Functor functor)
{
    B b;
    int y = b.f(functor()).x;  // ERRORS HERE
}

The parser gives two errors at the indicated line:

- Field 'x' could not be resolved
- Invalid arguments ' Candidates are: A f

These are bogus errors. The code is valid if g is instantiated with a Functor that does indeed return an int.

At most, the parser could complain if it detects that g is in fact being instantiated with a Functor that does not return an int, but even in that case the error should be at the instantiation site, not the definition site.
Comment 1 Markus Schorn CLA 2011-03-02 10:22:45 EST
Same root cause (function call on dependent name) as in bug 337686.

*** This bug has been marked as a duplicate of bug 337686 ***