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

Implicit conversion warning (#1682) reported even if static_cast is used

$
0
0

I ran into a strange issue when building the code with -Wconversion flag.

std::vector<int> values{0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
std::uint8_t number_of_values = static_cast<uint8_t>(values.size());

The example above produces a warning:

warning #1682: implicit conversion of a 64-bit integral type to a smaller integral type (potential portability problem)

values.size() returns size_t, so static_cast to uint8_t should be OK.

Enviroment:
Ubuntu 18.04.2
icc (ICC) 19.0.3.199 20190206


Viewing all articles
Browse latest Browse all 1175

Trending Articles



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