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

Warning in case of a explicit type cast

erling_andersen
New Contributor I
403 Views

I get the warning

src\cpub\bigint.c(45): warning #2259: non-pointer conversion from "unsigned __int64" to "uinteger32={unsigned int}" may lose significant bits
        x->a = (uinteger32) (y % BIGINTMAX);
Now in this case I make an explicit type cast which I know make everything safe. I think it would be natural if warnings occurs in the case with implicit casts. Is there a way to get Intel C to stop producing warning when I do explicit type casts.

 

0 Kudos
2 Replies
Judith_W_Intel
Employee
403 Views

 

This is a reasonable request and has already been made by other customers and is being tracked in our internal database as DPD200141748.

I assume you are using the -Wp64 switch and you know how to disable specific diagnostics with command line switches or pragmas.

Interestingly our compiler does not issue this warning consistently, i.e. if you look at the example below the warning is not emitted in bar2() but is emitted in bar():

typedef unsigned int uinteger32;
typedef unsigned __int64 __uint64;
__uint64 y;
__uint64 BIGINTMAX;

struct X {
   int a[3];
};

void bar(int i) {
  struct X* x;
  x->a = (uinteger32)(y%BIGINTMAX);  // Do not diagnose this - explicit cast
}

void bar2(int i) {
  struct X* x;
  __uint64 tmp = (y%BIGINTMAX);
  x->a = (uinteger32)tmp; // Also explicit cast, and we do not diagnose
}

0 Kudos
KitturGanesh
Employee
403 Views

Thanks Judy, I agree I couldn't reproduce the warning and I touched base with Melanie on this as well and wanted to get the preprocessed file from @erling_Andersen. Thanks for confirming the issue and I'll and for the issue CQ that's being tracked - appreciate much.

Kittur

0 Kudos
Reply