Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f964fe8

Browse files
committed
[CPP-434] Address comments regarding .ql and .qhelp.
1 parent 1d052a8 commit f964fe8

2 files changed

Lines changed: 12 additions & 12 deletions

File tree

cpp/ql/src/Likely Bugs/Arithmetic/SignedOverflowCheck.qhelp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@
44
<qhelp>
55
<overview>
66
<p>
7-
Testing for <code>signed</code> integer overflow by adding a
8-
value to a variable and then comparing the result to that variable
9-
is not defined by the C or C++ standards. The comparison may
10-
produce an unintended result, or may be deleted by the compiler
11-
entirely.
7+
Testing for signed integer overflow by adding a
8+
two signed values together and then comparing the result to one
9+
of the values is ill-formed since the overflow check is undefined.
10+
The comparison may produce an unintended result, or may be deleted
11+
by the compiler entirely.
1212
</p>
1313
</overview>
1414
<recommendation>
1515
<p>
16-
Make sure that the comparison in question uses <i>unsigned</i> values.
16+
When checking for overflow, make sure that <code>unsigned</code> values are used.
1717
</p>
1818
</recommendation>
1919
<example>

cpp/ql/src/Likely Bugs/Arithmetic/SignedOverflowCheck.ql

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* @name Undefined result of signed test for overflow
33
* @description Testing for overflow by adding a value to a variable
44
* to see if it "wraps around" works only for
5-
* `unsigned` integer values.
5+
* unsigned integer values.
66
* @kind problem
77
* @problem.severity warning
88
* @precision high
@@ -15,12 +15,12 @@ import cpp
1515
private import semmle.code.cpp.valuenumbering.GlobalValueNumbering
1616
private import semmle.code.cpp.rangeanalysis.SimpleRangeAnalysis
1717

18-
from RelationalOperation ro, AddExpr add, VariableAccess va1, VariableAccess va2
18+
from RelationalOperation ro, AddExpr add, Expr expr1, Expr expr2
1919
where
2020
ro.getAnOperand() = add and
21-
add.getAnOperand() = va1 and
22-
ro.getAnOperand() = va2 and
23-
globalValueNumber(va1) = globalValueNumber(va2) and
24-
add.getType().getUnspecifiedType().(IntegralType).isSigned() and
21+
add.getAnOperand() = expr1 and
22+
ro.getAnOperand() = expr2 and
23+
globalValueNumber(expr1) = globalValueNumber(expr2) and
24+
add.getUnspecifiedType().(IntegralType).isSigned() and
2525
exprMightOverflowPositively(add)
2626
select ro, "Testing for signed overflow may produce undefined results."

0 commit comments

Comments
 (0)