Bug 559737

Summary: False positive in C++ code analysis in container initilization with iterators when using namespace std
Product: [Tools] CDT Reporter: Halit Ongen <halitongen>
Component: cdt-parserAssignee: Project Inbox <cdt-parser-inbox>
Status: NEW --- QA Contact: Jonah Graham <jonah>
Severity: normal    
Priority: P3 CC: cdtdoug, jonah, marco.stornelli
Version: NextKeywords: core, regression, ui, usability
Target Milestone: ---   
Hardware: All   
OS: Linux   
Whiteboard:

Description Halit Ongen CLA 2020-01-31 04:47:40 EST
-- Configuration Details --
Product: Eclipse IDE 4.14.0.20191212-1200 (org.eclipse.epp.package.cpp.product)Installed Features:
 org.eclipse.platform 4.14.0.v20191210-0610

False positive in C++ code analysis. An error is presented as a red underline when a container is assigned to a container of the same type initialized with iterators. The code compiles and runs as intended. Reproducible in a clean install in both Linux and Mac. Example:

#include <vector>

using namespace std;

int main(void) {
	vector <int> foo(5,1);                                                                                                      //No error
	vector <int> bar(foo.begin(),foo.end());                                                                         //No error
	vector <int> cpp11 = {1,2,3,4,5};                                                                                  //No error
	vector <int> whyIsThisAnError = vector <int> (foo.begin(),foo.end());                       //ERROR
	vector <int> whyIsntThisAnError = std::vector <int> (foo.begin(),foo.end());             //No error
	return 0;
}
Comment 1 Marco Stornelli CLA 2020-02-01 02:53:39 EST
Reassigned to parser component since Codan checker just reports problem bindings, nothing more.