-
Notifications
You must be signed in to change notification settings - Fork 2k
Expand file tree
/
Copy pathAV Rule 147.qhelp
More file actions
44 lines (32 loc) · 1.14 KB
/
AV Rule 147.qhelp
File metadata and controls
44 lines (32 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<!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="../jsfNote.inc.qhelp" />
<p>
This query highlights portions of code that can expose the floating point implementation of the underlying
machine. Manually manipulating the bits in the float is prone to mistakes and is unportable. Floating point
implementations can vary across architectures, and bit-field packing can differ across compilers,
making manual bit-manipulation of floats inadvisable.
</p>
<p>
The bits of a floating point could be exposed by:
</p>
<ul>
<li>casting a float pointer to a pointer of another type</li>
<li>casting a float array to a non-float pointer type</li>
<li>using a float in a union with another type</li>
</ul>
</overview>
<recommendation>
<p>
Do not expose the bit contents of a float.
</p>
</recommendation>
<example><sample src="AV Rule 147.cpp" />
</example>
<references>
<li>AV Rule 147, <em>Joint Strike Fighter Air Vehicle C++ Coding Standards</em>. Lockheed Martin Corporation, 2005.
</li></references></qhelp>