|
![]() Click on image to see enlargment |
|
PC-lint/FlexeLint Output | Reference Manual Explanation | Home bug649.cpp
Leantes was quite proud of his program to extract fields from 32 bit words in such a way that through the magic of constant folding much of the arithmetic can be done at compile time. And it even works, mostly, but it has a slight flaw. Can you spot it? bug649.cpp lint Output
--- Module: bug649.cpp (C++)
_
#... (High_Mask((5)+1-(3)) >> (31 - (5)))
#... ((Mask(5,3) & 0x5E) >> 3)
printf( "%x\n", Extract(0x5E,5,3) );
bug649.cpp(19) : Info 702: Shift right of signed quantity (int)
_
#... (High_Mask((5)+1-(3)) >> (31 - (5)))
#... ((Mask(5,3) & 0x5E) >> 3)
printf( "%x\n", Extract(0x5E,5,3) );
bug649.cpp(19) : Warning 649: Sign fill during constant shift
_
printf( "%x\n", Extract(0x5E,5,3) );
bug649.cpp(19) : Info 702: Shift right of signed quantity (int)
bug649.cpp(19) : Warning 649: Sign fill during constant shift
Reference Manual Explanation
649 Sign fill during constant shift -- During the evaluation of a constant
expression a negative integer was shifted right causing sign fill of
vacated positions. If this is what is intended, suppress this error,
but be aware that sign fill is implementation-dependent.
CommentaryOur commentary from the manual seems to say it all. It's really a neat feature to obtain a mask by shifting a hi bit left, unless that "feature" is not uniformly supported. If you have comments or questions about this bug, please post them to our Discussion Forum |
Previous Bug - Bug #671 - July 2007