|
PC-lint/FlexeLint Output | Reference Manual Explanation | Home Page bug542.cpp
Why does this program say that the bit is OFF when we just turned it ON?
bug542.cpp lint Output
--- Module: bug542.cpp
_
struct { int bit:1; } s;
bug542.cpp(4) : Info 806: Small bit field is signed rather than unsigned
_
s.bit = 1;
bug542.cpp(14) : Warning 542: Excessive size for bit field
Reference Manual Explanation
542 Excessive size for bit field -- An attempt was made to assign a
value into a bit field that appears to be too small. The value
to be assigned is either another bit field larger than the
target, or a numeric value that is simply too large. You may
cast the value to the generic unsigned type to suppress the
error.
You may get this message unexpectedly if the base of the bit
field is an int. For example:
struct { int b : 1 } s;
s.b = 1; /* Warning - - requires 0 or -1 */
The solution in this case is to use 'unsigned' rather than 'int'
in the declaration of b.
|
Previous Bug - Bug #1536 - May 2001