-
Notifications
You must be signed in to change notification settings - Fork 2k
Expand file tree
/
Copy pathAV Rule 197.qhelp
More file actions
40 lines (30 loc) · 1.06 KB
/
AV Rule 197.qhelp
File metadata and controls
40 lines (30 loc) · 1.06 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
<!DOCTYPE qhelp PUBLIC
"-//Semmle//qhelp//EN"
"qhelp.dtd">
<qhelp>
<overview>
<p>
This rule finds <code>float</code> variables being used as loop counter. <code>float</code> values
are prone to rounding and truncation. In particular, very large and very small
float values are prone to rounding errors and could lead to unexpected loop behavior.
</p>
</overview>
<recommendation>
<p>
Use an integral variable instead of a float variable for the loop counter.
</p>
</recommendation>
<example><sample src="AV Rule 197.cpp" />
</example>
<references>
<li>
AV Rule 197, <em>Joint Strike Fighter Air Vehicle C++ Coding Standards</em>. Lockheed Martin Corporation, 2005.
</li>
<li>
MISRA C++ Rule 6-5-1, <em>Guidelines for the use of the C++ language in critical systems</em>. The Motor Industry Software Reliability Associate, 2008.
</li>
<li>
<a href="https://www.securecoding.cert.org/confluence/display/c/FLP30-C.+Do+not+use+floating-point+variables+as+loop+counters">FLP30-C. Do not use floating-point variables as loop counters</a>
</li>
</references>
</qhelp>