casting and remark #2259

casting and remark #2259

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;

3 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

For the static_cast, icc shouldn't issue warning. It's in our bug tracking system now. Thanks for the posting.

this issue has been fixed in 12.1 and newer.

sorry for the delayed update.


Leave a Comment

Please sign in to add a comment. Not a member? Join today