- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
// 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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
( 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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
What is your environment to in the original issue?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Happy to learn that you found the workarround.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Can you try attached code snippet with compilation options in the batch files and let me know if you can reproduce it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page