Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 338611 - Parser error when using decltype
Summary: Parser error when using decltype
Status: RESOLVED FIXED
Alias: None
Product: CDT
Classification: Tools
Component: cdt-indexer (show other bugs)
Version: 8.0   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 8.1.1   Edit
Assignee: Sergey Prigogin CLA
QA Contact: Markus Schorn CLA
URL:
Whiteboard:
Keywords:
Depends on: 299911
Blocks:
  Show dependency tree
 
Reported: 2011-03-01 20:17 EST by Nathan Ridge CLA
Modified: 2012-08-18 23:31 EDT (History)
3 users (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 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.