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

Error #2259

abhijeet_thatte
Beginner
1,191 Views
Hi,

I am trying to compile an original VC based project on Intel compiler. I have kept -Werror option ON treating warning as errors.

I am getting an error
"error #2259: non-pointer conversion from "unsigned __int64" to "UINT32={unsigned int}" may lose significant bits" for the following code snippet.

struct_array[count].var_32 = (uint32) GET_2BYTE(var_64,__no).

GET_2BYTE macro is defines as below:
#define GET_2BYTE(__word, __no) (((__word) >> ((__no) * 16)) & 0xFFFF)

So, I am trying to typecast a 64 bit variable into 32 bit.

I assume macro is not a reason for this warning/error as it is just creating an offset.

Is there any way to avoid this error without turning of -Werror option.


Thanks
0 Kudos
10 Replies
Om_S_Intel
Employee
1,192 Views
I am trying to create a testcase to reproduce your issue. I am provinding it below:

// testcase U81090

#define GET_2BYTE(__word, __no) (((__word) >> ((__no) * 16)) & 0xFFFF)

typedef unsigned int uint32;

struct node {

int var_32;

int y;

};

int main()

{

int count;

node struct_array[100];

long long var_64 = 300;

int __no = 4;

for (int i = 0; i < 100; ++i)

{

struct_array.var_32 =i;

struct_array.y = i+100;

}

count = 5;

struct_array[count].var_32 = (uint32) GET_2BYTE(var_64,__no);

return 0;

}


I could compile the above code segment as below:

c:\>icl -c tstcase.cpp

Intel C++ Intel 64 Compiler XE for applications running on Intel 64, Version 12.0.1.127 Build 20101116

Copyright (C) 1985-2010 Intel Corporation. All rights reserved.

tstcase.cpp

The macro seems working. My data types may be different from yours. Could you please let me if I am missing something here.

0 Kudos
bernaske
New Contributor I
1,192 Views
Hi,

( Error #2259 )

i have your sample tstcase.cpp compile with the Intel C++ 12.0 (XE) on openSUSE 11.4 RC 2 64 Bit Linux,
turned all Warning Flags, with the icpc the compled compile correct, no errors no critical warnings
i think thats a problem from environment (OS ) or both OS and Compiler


regards
Franz
0 Kudos
Om_S_Intel
Employee
1,192 Views
I compiled the testcase on Windows 7 using VS2010 and Intel C++ composer XE.

What is your environment to in the original issue?
0 Kudos
bernaske
New Contributor I
1,192 Views
Hi,

my Environment is :

operating System: openSUSE 11.4 RC 2 64 Bit Linux

Hardware: ASUS Sabertooth X58
Processor: Intel i7-950

RAM : 8 GByte

Developing Environment: Intel Parallel Studio XE update 1 intel64 and Composer XE update_1 intel 64


best regards
Franz



0 Kudos
abhijeet_thatte
Beginner
1,192 Views
Hi,

Even I have written a small test program and it works without any warnings.

So, I tweaked the troublesome code to following.

local_var_64 = GET_2BYTE(var_64,__no)
struct_array[count].var_32 = (uint32) local_var_64 and it works.

This is very weird. I never expected it to work. (It was a desparate attempt with no logic). Now I am not sure why compiler is allowing this.
One more thing I have noticed is that it only happens when I am typcasting 64bit to something else. Other typecastings look good.

My build environment is:
Windows 7 64 bit
VC 2005 with Intel C++ Intel 64 Compiler XE on Intel 64, Version 12.0.2.154 Build 20110112.

I can't use this stupid solution. Is there any other way to find the root cause.


Thanks,
Abhi
0 Kudos
abhijeet_thatte
Beginner
1,192 Views
Keep /WX compilation option ON and you shall see the error. /WX is a culprit.
0 Kudos
abhijeet_thatte
Beginner
1,192 Views
Oh i m sorry! It is /Wp64 which enables 64 bit porting warning messages. But I wonder why VC was not giving errors.
0 Kudos
Om_S_Intel
Employee
1,192 Views
I used both /WX and /Wp64 options. I am unable to reproduce the issue.

Happy to learn that you found the workarround.
0 Kudos
abhijeet_thatte
Beginner
1,192 Views
Though I have found a workaround, I am not sure why it gives those errors. On VC2005 64 bit compilation they are deprecated. But Intel compiler bugs me even after doing 64 bit compilation.

Can you try attached code snippet with compilation options in the batch files and let me know if you can reproduce it.
0 Kudos
Om_S_Intel
Employee
1,192 Views

The warning is correct for your test case.

C:\>icl -c /Wp64 warning.c

Intel C++ Intel 64 Compiler XE for applications running on Intel 64, Version 12.0.1.127 Build 20101116

Copyright (C) 1985-2010 Intel Corporation. All rights reserved.

warning.c

warning.c(10): warning #2259: non-pointer conversion from "unsigned __int64" to

"unsigned int" may lose significant bits

local_node.var_32 = (unsigned int) (y & 0xFFFF);

^


You are using /WX option. This option forces compiler to convert warnings into errors.

0 Kudos
Reply