Quantcast
Channel: Intel® Software - Intel® C++ Compiler
Viewing all articles
Browse latest Browse all 1175

vector size bug

$
0
0

When I am running this program, it will return wrong results, which are shown in the comments.

 

#include <iostream>
#include <vector>

int main()
{
  size_t n = 1000000000;
  std::vector<double> V(n);
  std::cout << V.size() << std::endl;
  // output: 1000000000

  std::cout << V.size() << std::endl;
  // output: 18446744073635809792

  std::cout << V.capacity() << std::endl;
  // output: 1000000000

  return 0;
}
 

icc for Mac

Version 19.0.1.144 Build 20181018


Viewing all articles
Browse latest Browse all 1175

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>