Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Rule 4-5-1 prohibits 'b1 |= b2;' ?
#3
Remember that any non-zero value will be considered as 'true' within a logical context, which can lead to surprises:

Code:
a = 0x01u;   // This is logically 'true'
b = 0x10u;   // This is logically 'true'

if ( a &  b )   // Result of bit-wise 'and' is 'false'
if ( a && b )   // Result of logical 'and' is true
Rule 4-5-1 helps to enforce a consistent use of boolean types, helping to allowing defects to be detected.
<t></t>
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)