Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 329795 - dereferencing iterator results in "field could not be resolved" error
Summary: dereferencing iterator results in "field could not be resolved" error
Status: RESOLVED FIXED
Alias: None
Product: CDT
Classification: Tools
Component: cdt-core (show other bugs)
Version: 8.0   Edit
Hardware: All All
: P3 minor (vote)
Target Milestone: 8.0   Edit
Assignee: Markus Schorn CLA
QA Contact: Doug Schaefer CLA
URL:
Whiteboard:
Keywords:
: 333186 (view as bug list)
Depends on:
Blocks:
 
Reported: 2010-11-09 09:42 EST by Michal Spadlinski CLA
Modified: 2016-03-09 10:21 EST (History)
2 users (show)

See Also:


Attachments
c++ testcase (406 bytes, application/octet-stream)
2010-11-09 09:45 EST, Michal Spadlinski CLA
no flags Details
testcase + fix (3.11 KB, patch)
2010-11-11 11:29 EST, Markus Schorn CLA
mschorn.eclipse: iplog-
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Michal Spadlinski CLA 2010-11-09 09:42:49 EST
Build Identifier: eclipse helios 20100917-0705, CDT Version: 8.0.0.201011050851  Build id: 201011050851

The following testcase shows the problem:

#include <iostream>
#include <list>

struct SampleStr {
	int foo, bar;
};

int main(int argc, char** argv)
{
	std::list< SampleStr > structList;
	std::list< SampleStr >::const_iterator e2 = structList.begin(), _e2 = structList.end();

	for (; e2 != _e2; ++ e2) {
		std::cout << (*e2).foo << std::endl;
	}

	for (; e2 != _e2; ++ e2) {
		std::cout << e2->foo << std::endl;
	}
	return 0;
}

The line with (*e2).foo is underlined as error: "field could not be resolved", although e2->foo seems to be parsed without problem.

Reproducible: Always
Comment 1 Michal Spadlinski CLA 2010-11-09 09:45:07 EST
Created attachment 182718 [details]
c++ testcase

Test-case showing "field could not be resolved" problem
Comment 2 Markus Schorn CLA 2010-11-09 10:07:42 EST
I cannot reproduce the problem. Most likely it depends on the specific system headers you are using. Please try the following:

* Create a new project and try to reproduce the issue with the single test file.
* In case the problem is still there, please run the preprocessor on the test
  file and attach the output (gcc -E -P test.cpp). I will try to reproduce the
  problem with that.
Comment 3 Michal Spadlinski CLA 2010-11-09 11:02:03 EST
(In reply to comment #2)
> I cannot reproduce the problem. Most likely it depends on the specific system
> headers you are using. Please try the following:
> 

I'm using headers from MSVC 2005, maybe that's the problem.
In "C/C++ General" -> "Paths and Symbols" -> Includes -> GNU C++
I'm adding include dir:
MSVC8Location\VC\include

> * Create a new project and try to reproduce the issue with the single test
> file.

done, again the same

> * In case the problem is still there, please run the preprocessor on the test
>   file and attach the output (gcc -E -P test.cpp). I will try to reproduce the
>   problem with that.

I can send you output from (cl /EP /P, that's similar to gcc -E -P)
if that would help.
(I'd prefer sending it on e-mail instead of attaching it here)
Comment 4 Markus Schorn CLA 2010-11-09 11:28:10 EST
(In reply to comment #3)
> I'm using headers from MSVC 2005, maybe that's the problem.
> In "C/C++ General" -> "Paths and Symbols" -> Includes -> GNU C++
> I'm adding include dir:
> MSVC8Location\VC\include
Ok, I have an installation of a microsoft compiler on my machine, I'll try to reproduce the issue with its headers.

> I can send you output from (cl /EP /P, that's similar to gcc -E -P)
> if that would help.
> (I'd prefer sending it on e-mail instead of attaching it here)
If I cannot reproduce the isse, we can try that.
Comment 5 Markus Schorn CLA 2010-11-11 11:29:36 EST
Created attachment 182912 [details]
testcase + fix

Thanks, I can reproduce the issue with the microsoft headers.
Comment 6 Markus Schorn CLA 2010-11-11 11:30:07 EST
Fixed in 8.0 > 20101111.
Comment 8 Markus Schorn CLA 2011-01-07 05:16:03 EST
*** Bug 333186 has been marked as a duplicate of this bug. ***
Comment 9 Benjamin Shadwick CLA 2016-03-09 10:21:19 EST
I was seeing the same issue with Mars.1 when trying to return ->second from a left- or right-side iterator to a Boost.Bimap. When I backed out "second" and hit ctrl+space (and then waited 10-15 seconds) to bring up the content assist list, "second" was listed. When I picked it, the errors went away.

I guess CDT doesn't fully untangling the Boost/STL craziness until you engage content assist? I rarely use content assist, because I can't get the list to pop up in under 10 seconds even with everything but parsing suggestions disabled and with indexing of not-in-build source files and unused headers both disabled.