Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 317085 - Resolution of types in namespace std behaves different from other types in other namespaces
Summary: Resolution of types in namespace std behaves different from other types in ot...
Status: CLOSED INVALID
Alias: None
Product: CDT
Classification: Tools
Component: cdt-indexer (show other bugs)
Version: 7.0   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact: Markus Schorn CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-06-16 13:57 EDT by Lukas Felber CLA
Modified: 2010-06-30 17:18 EDT (History)
0 users

See Also:


Attachments
testproject (3.85 KB, application/octet-stream)
2010-06-30 05:34 EDT, Markus Schorn CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Lukas Felber CLA 2010-06-16 13:57:03 EDT
Build Identifier: Build id: I20100312-1448

Initial condition: Empty C++ project where "string" was added to the "KEY_FILES_TO_PARSE_UP_FRONT" indexer properties and KEY_INDEX_UNUSED_HEADERS_WITH_DEFAULT_LANG was set to true. The project was then reindexed.

Code:
using namespace std;
string s;

Problem: even if the string type definition (which of course is in namespace std) is indexed, the indexer is not capable to resolve "string" in the given code (he is able to do so if "string s" is replaced with "std::string s").
The strange thing is that if one adds an empty namespace-definition to the code the resolution gets possible:

new code:
namespace std { }
using namespace std;
string s;

also strange: this problem is only present for the namespace std. consider the following code:
//main.cpp
using namespace X;
using namespace std;
string s;
MyStd s2;
MyX x;
//test.h
class MyC { };
namespace X { class MyX {}; }
namespace std {	class MyStd {}; }

Resoltion to MyX is possible here. Resolution to my own type added to std (std::MyStd) is not possible, same as string which is also not resolvable. When an empty namespace definition "namespace std { }" is added to the main.cpp the resolution of both string and MyStd gets possible.

Obviously, I would be most happy if the indexer would always be able to resolve std types (regardless of empty namespace definitions)

Reproducible: Always
Comment 1 Markus Schorn CLA 2010-06-17 03:41:14 EDT
I cannot reproduce the problem. How do you observe that the name cannot be resolved?
Comment 2 Lukas Felber CLA 2010-06-24 08:10:47 EDT
I can observe that the name is not resolvable by ctrl+clicking on it.

Note that the problem is only present if there is no include to <string>. I believe that then the resolution of string gets possible becuase inside of <string> there of course is a definition of the namespace std (which then has the same effect the example code "new code:" in my previous comment).
Comment 3 Markus Schorn CLA 2010-06-30 05:34:31 EDT
Created attachment 173073 [details]
testproject

I have no clue, this works for me with the attached project.
Comment 4 Lukas Felber CLA 2010-06-30 17:18:32 EDT
> I have no clue, this works for me with the attached project.

hm... interesting. Your attachment project works fine for me. After I run my analysis tool, however, ctrl+clicking on "string" doesn't works any more. Strange. There must be something that I missed. I will contact you when I find out what it is.

I will close the ticket until I find out more.