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

casting and remark #2259

sgwood
Beginner
285 Views

It looks like the compiler warning: remark #2259: non-pointer conversion from "double" to "float" may lose significant bits, does not go away with the C++ static_cast<> constructs.

If you compile the following example with the -w2 option you will see that the compiler issues remark #2259 for the static_cast line. I'm user version 11.0.074 of the C++ compiler.

int main() {
double x = 3.4;

//This line will create a warning (as it should)

float y1 = x;

//This line will not create a warning (because of the cast)

float y2 = (float)(x);

//This line will create a warning (the cast should prevent it)

float y3 = static_cast(x);

cout << y1<< endl;

cout << y2 << endl;

cout << y3 << nedl;
return 0;
}

0 Kudos
2 Replies
JenniferJ
Moderator
285 Views
For the static_cast, icc shouldn't issue warning. It's in our bug tracking system now. Thanks for the posting.

0 Kudos
JenniferJ
Moderator
285 Views

this issue has been fixed in 12.1 and newer.

sorry for the delayed update.

Jennifer

0 Kudos
Reply