File tree Expand file tree Collapse file tree 3 files changed +6
-7
lines changed
src/Likely Bugs/Arithmetic
test/query-tests/Likely Bugs/Arithmetic/IntMultToLong Expand file tree Collapse file tree 3 files changed +6
-7
lines changed Original file line number Diff line number Diff line change @@ -218,7 +218,9 @@ where
218218 // only report if we cannot prove that the result of the
219219 // multiplication will be less (resp. greater) than the
220220 // maximum (resp. minimum) number we can compute.
221- overflows ( me , t1 )
221+ overflows ( me , t1 ) and
222+ // exclude cases where the expression type may not have been extracted accurately
223+ not me .getParent ( ) .( Call ) .getTarget ( ) .hasAmbiguousReturnType ( )
222224select me ,
223225 "Multiplication result may overflow '" + me .getType ( ) .toString ( ) + "' before it is converted to '"
224226 + me .getFullyConverted ( ) .getType ( ) .toString ( ) + "'."
Original file line number Diff line number Diff line change @@ -6,9 +6,9 @@ void test_float_double1(float f, double d) {
66 double r3 = f * f ; // BAD
77 double r4 = f * d ; // GOOD
88
9- float f1 = fabsf (f * f ); // GOOD [FALSE POSITIVE]
9+ float f1 = fabsf (f * f ); // GOOD
1010 float f2 = fabsf (f * d ); // GOOD
11- double f3 = fabs (f * f ); // BAD
11+ double f3 = fabs (f * f ); // BAD [NOT DETECTED]
1212 double f4 = fabs (f * d ); // GOOD
1313}
1414
@@ -23,6 +23,6 @@ void test_float_double2(float f, double d) {
2323
2424 float f1 = fabsf (f * f ); // GOOD
2525 float f2 = fabsf (f * d ); // GOOD
26- double f3 = fabs (f * f ); // BAD
26+ double f3 = fabs (f * f ); // BAD [NOT DETECTED]
2727 double f4 = fabs (f * d ); // GOOD
2828}
Original file line number Diff line number Diff line change 11| Buildless.c:6:17:6:21 | ... * ... | Multiplication result may overflow 'float' before it is converted to 'double'. |
2- | Buildless.c:9:22:9:26 | ... * ... | Multiplication result may overflow 'float' before it is converted to 'double'. |
3- | Buildless.c:11:22:11:26 | ... * ... | Multiplication result may overflow 'float' before it is converted to 'double'. |
42| Buildless.c:21:17:21:21 | ... * ... | Multiplication result may overflow 'float' before it is converted to 'double'. |
5- | Buildless.c:26:22:26:26 | ... * ... | Multiplication result may overflow 'float' before it is converted to 'double'. |
63| IntMultToLong.c:4:10:4:14 | ... * ... | Multiplication result may overflow 'int' before it is converted to 'long long'. |
74| IntMultToLong.c:7:16:7:20 | ... * ... | Multiplication result may overflow 'int' before it is converted to 'long long'. |
85| IntMultToLong.c:18:19:18:23 | ... * ... | Multiplication result may overflow 'float' before it is converted to 'double'. |
You can’t perform that action at this time.
0 commit comments