<!DOCTYPE qhelp PUBLIC
  "-//Semmle//qhelp//EN"
  "qhelp.dtd">
<qhelp>


<overview>

<!-- Mention that this rule may not be applicable in projects that don't follow the JSF standard. -->
<include src="cpp/jsfNote.qhelp" />

<p>
This query finds bit fields with members that are not explicitly declared to be unsigned.
The sign of plain char, short, int, or long bit field is implementation-specific, and declaring
them all to be unsigned removes the ambiguity and ensures portability.
</p>
</overview>

<recommendation>
<p>
Declare all members of the bit field to be unsigned.
</p>
</recommendation>

<example>
<p>The code below shows two examples of bit fields. The second field is declared to be unsigned which ensures portability. 
The first field should also be declared to be unsigned.
</p>
<sample src="AV Rule 154.cpp" />
</example>

<references>
<li>
  AV Rule 154, <em>Joint Strike Fighter Air Vehicle C++ Coding Standards</em>. Lockheed Martin Corporation, 2005.
</li>
<li>
  C++ reference: <a href="http://en.cppreference.com/w/cpp/language/bit_field">Bit Fields</a>
</li>
</references>
</qhelp>
