I use a std::map (from #include <map> ) in my Code (see minimal example below).
After compiling with the Intel Composer 2013 I analyzed my program with the Intel Inspector XE. I got various "Invalid Memory Access" errors. The errors are located in "xmemory", which is not from me. The last line in my Code is a call to the std::map.
If I compile with the Mircosoft compiler, integrated in Visual Studio 2010, and analyzed my program the Intel Inspector does not find any Error.
Question: Is that...
- .. a problem in the code?
- ... a problem of the std::map implementation?
- .. just a false positive from the Inspector?
Please find attached a example Visual Studio (2010) project. Inclusive an Inspector result with the problems.
Compiler settings are default of Visual Studio (for Debug mode), but for x64 and with the Intel compiler.
My minimal code example: (copied from here)
using namespace std;
map<string, int*> Employees;
int a = 5234;
int b = 3374;
int c = 1923;
int d = 7582;
// Examples of assigning Map container contents
// 1) Assignment using array index notation
Employees["Mike C."] = &a;
Employees["Charlie M."] = &b;
// 2) Assignment using member function insert() and STL pair
Employees.insert(std::pair<string,int*>("David D.",&c)); //makes 3 "Invalid memory access"
// 3) Assignment using member function insert() and "value_type()"
// 4) Assignment using member function insert() and "make_pair()"
Employees.insert(std::pair<string, int*>("Peter Q.",&d));
cout << "Map size: " << Employees.size() << endl;
for( map<string, int*>::iterator ii=Employees.begin(); ii!=Employees.end(); ++ii)
cout << (*ii).first << ": " << *(*ii).second << endl;
- Windows 7
- Visual Studio 2010
- Intel® C++ Composer XE 2013 Update 5 Integration for Microsoft* Visual Studio* 2010
- Intel® Inspector XE 2013 Update 6, (build 283349)
I can reproduce it, and will look into it further (these are false positives from IXE).
There is an unrelated issue in the project settings. Under Properties->C/C++->Code Generation, the "Basic Runtime Checks" should be turned off (set to "Default"). In particular, the stack frames check (/RTCs) will initialize the stack to some non-zero value, and IXE will then consider the stack to be initialized. With this property change, IXE is able to find uninitialized accesses introduced into the example (for instance, change "int a = 5234;" to "int a;")
Thanks for your answer and explanation.
I think the point with the project settings is not unrelated. With turned off "Basic Runtime Checks" I get no errors shown anymore by the Inspector.
Sergey your are showing the output of program. But the output of the program was not the problem. The output was always correct.
The problem was the output of the Intel Inspector Tool. The Inspector had detected some "Invalid Memory Access" inside a file called "xmemory" which is releated to the std::map.