|
![]() Click on image to see enlargment |
|
PC-lint/FlexeLint Output | Reference Manual Explanation | Home bug806.cpp
The pumpkin producers wanted a nose and two eyes but this quality assurance program keeps printing 'malformed'. What's the problem? bug806.cpp lint Output--- Module: bug806.cpp
_
struct pumpkin { int nose:1, eyes:2; } p = { 1, 2 };
bug806.cpp(3) : Info 806: Small bit field is signed rather than unsigned
bug806.cpp(3) : Info 806: Small bit field is signed rather than unsigned
bug806.cpp(3) : Warning 542: Excessive size for bit field
bug806.cpp(3) : Warning 542: Excessive size for bit field
_
if( p.nose > 0 && p.eyes > 1 ) return 1;
bug806.cpp(7) : Warning 685: Relational operator '>' always evaluates to 'false'
bug806.cpp(7) : Warning 685: Relational operator '>' always evaluates to 'false'
Reference Manual Explanation
806 Small bit field is signed rather than unsigned -- A small bit field
(less than an int wide) was found and the base type is signed rather
than unsigned. Since the most significant bit is a sign bit this
practice can produce surprising results. For example,
struct { int b:1; } s;
s.b = 1;
if( s.b > 0 ) /* should succeed but actually fails */
...
If you have comments or questions about this bug, please post them to our Discussion Forum |
Previous Bug - Bug #785 - September 2004