mirror of
https://github.com/github/codeql.git
synced 2026-04-30 19:26:02 +02:00
CPP: Test wrapped rounding functions more thoroughly.
This commit is contained in:
@@ -7,3 +7,4 @@
|
||||
| test.cpp:101:10:101:12 | call to pow | Return value of type double is implicitly converted to int here. |
|
||||
| test.cpp:103:10:103:12 | call to pow | Return value of type double is implicitly converted to int here. |
|
||||
| test.cpp:105:10:105:12 | call to pow | Return value of type double is implicitly converted to int here. |
|
||||
| test.cpp:130:10:130:17 | call to myRound3 | Return value of type double is implicitly converted to int here. |
|
||||
|
||||
@@ -106,14 +106,26 @@ int test2(double v, double w, int n)
|
||||
};
|
||||
}
|
||||
|
||||
double myRound(double v)
|
||||
double myRound1(double v)
|
||||
{
|
||||
return round(v);
|
||||
}
|
||||
|
||||
double myRound2(double v)
|
||||
{
|
||||
double result = round(v);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
double myRound3(double v)
|
||||
{
|
||||
return (v > 0) ? round(v) : 0;
|
||||
}
|
||||
|
||||
void test3()
|
||||
{
|
||||
int i = myRound(1.5); // GOOD
|
||||
int i = myRound1(1.5); // GOOD
|
||||
int j = myRound2(2.5); // GOOD
|
||||
int k = myRound3(3.5); // GOOD [FALSE POSITIVE]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user