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

Bug 338611

Summary: Parser error when using decltype
Product: [Tools] CDT Reporter: Nathan Ridge <zeratul976>
Component: cdt-indexerAssignee: Sergey Prigogin <eclipse.sprigogin>
Status: RESOLVED FIXED QA Contact: Markus Schorn <mschorn.eclipse>
Severity: normal    
Priority: P3 CC: cdtdoug, eclipse.sprigogin, yevshif
Version: 8.0   
Target Milestone: 8.1.1   
Hardware: All   
OS: All   
Whiteboard:
Bug Depends on: 299911    
Bug Blocks:    

Description Nathan Ridge CLA 2011-03-01 20:17:11 EST
Here is test.hpp:

template <typename T>
class A {};
    
template <typename T>
A<T> h(T);

template <typename T>
auto g(T t) -> decltype(h(t));


Here is test.cpp:

#include "test.hpp"

void f()
{
    g(0);  // ERROR HERE
}


The parser gives the following error:

Invalid arguments ' Candidates are: ? g(#0) '

The code compiles fine with g++ >= 4.4
Comment 1 Nathan Ridge CLA 2011-03-01 20:23:56 EST
I should note that if I copy-and-paste the contents of test.hpp into test.cpp in place of the #include, the error goes away. This is not the first time I've seen this behaviour, and I am very curious as to why it happens.
Comment 2 Markus Schorn CLA 2011-03-02 04:30:52 EST
Currently we cannot properly store dependent types involving decltype.
Comment 3 Nathan Ridge CLA 2011-03-30 20:20:59 EDT
I'm not sure whether this (and the bug it depends on) is planned to be fixed for 8.0, but if not, would it be possible to disable the generation of "Invalid arguments ..." error bindings for functions where the parser is unable to deduce to return type or argument types?

I think users would rather the parser fail to report a few legitimate errors, than report errors for valid code.
Comment 4 Sergey Prigogin CLA 2012-08-18 23:31:03 EDT
Fixed together with bug 299911.