http://llvm.org/bugs/show_bug.cgi?id=11572
Bug #: 11572
Summary: Right shift of a bit field strips the "unsigned" type
property from a bitfield
Product: clang
Version: 3.0
Platform: PC
OS/Version: Linux
Status: NEW
Severity: normal
Priority: P
Component: C++
AssignedTo: [email protected]
ReportedBy: [email protected]
CC: [email protected], [email protected]
Classification: Unclassified
Created attachment 7730
--> http://llvm.org/bugs/attachment.cgi?id=7730
source file for the bug
With the following test source:
class Example {
public:
unsigned int lock : 26;
unsigned int v1 : 3;
unsigned int v2 : 3;
inline unsigned int getPermission(unsigned int key)
{
if( key != 0 ){
if( ( key >> 24 ) < ( lock >> 24 ) )
return (unsigned int)( v1 );
else
return (unsigned int)( v2 );
}
return 7;
};
};
I get a warning on the compare when -Wsign-compare is in effect.
va-sa.cpp:10:31: warning: comparison of integers of different signs:
'unsigned int' and 'int' [-Wsign-compare]
if( ( key >> 24 ) < ( lock >> 24 ) )
~~~~~~~~~ ^ ~~~~~~~~~~
What seems to have happened is that the >> operator strips the "unsigned"
property when the left operand is a bit field. Both the use of a bit field
and the use of the >> operator are needed to trigger the warning.
g++ 4.5.3 doesn't give a warning for this.
--
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs