- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The following code fails to compile with icpc version 16.0.2 20160204 on OS X 10.11.4, but compiles fine with Clang and GCC:
#include <iostream> #include <map> int main( int argc, char** argv ) { std::map<int,int> test_map{ {1,2}, {3,4}, {5,6} }; auto voxel_iterator{ test_map.find( 5 ) }; //auto voxel_iterator = test_map.find( 5 ); std::cout << voxel_iterator->first << " -> " << voxel_iterator->second << std::endl; }
I receive the following error when compiling the code with 'icpc -std=c++11 main.cpp':
main.cpp(8): error: expression must have pointer type std::cout << voxel_iterator->first << " -> " << voxel_iterator->second << std::endl; ^ main.cpp(8): error: expression must have pointer type std::cout << voxel_iterator->first << " -> " << voxel_iterator->second << std::endl;
It seems that icpc is not deducing the return type of find as an iterator when uniform initialization syntax is used. Replacing uniform initialization with '=' (see the commented line) results in the correct type deduction. Is this the expected behavior with uniform initialization?
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for the report -- it looks like this was already recently reported here:
https://software.intel.com/en-us/forums/intel-c-compiler/topic/621832
It looks like this is only supported in GNU 5.0 and later versions, earlier versions of GNU give an error similar to icpc.
I can see that you've already identified an alternate syntax that you can use as a workaround.
Judy

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page