Community
cancel
Showing results for 
Search instead for 
Did you mean: 
154 Views

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

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

0 Kudos
2 Replies
Vladimir_S_3
Beginner
154 Views

I can confirm the same behavior for icpc v 19.0.4.

Would be really great to get a fix. It complains about lots of third-party code. 

Viet_H_Intel
Moderator
154 Views

You can suppress it by -wd1682

Reply