Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.

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

Vasiljevski__Nikola
662 Views

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
662 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. 

0 Kudos
Viet_H_Intel
Moderator
662 Views

You can suppress it by -wd1682

0 Kudos
Reply