Skip to content

Commit fcfdf81

Browse files
committed
C++: Exclude compiler generated variables from a case in 'cpp/leap-year/unsafe-array-for-days-of-the-year'.
1 parent f0de9c3 commit fcfdf81

3 files changed

Lines changed: 2 additions & 2 deletions

File tree

cpp/ql/src/Likely Bugs/Leap Year/UnsafeArrayForDaysOfYear.ql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ where
2626
or
2727
exists(Variable var |
2828
var = element and
29+
not var.isCompilerGenerated() and
2930
var.getType() instanceof LeapYearUnsafeDaysOfTheYearArrayType and
3031
allocType = "an array allocation"
3132
)
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
| test.cpp:17:6:17:10 | items | There is an array allocation with a hard-coded set of 365 elements, which may indicate the number of days in a year without considering leap year scenarios. |
22
| test.cpp:25:15:25:26 | new[] | There is an array allocation with a hard-coded set of 365 elements, which may indicate the number of days in a year without considering leap year scenarios. |
33
| test.cpp:52:20:52:23 | call to vector | There is a std::vector allocation with a hard-coded set of 365 elements, which may indicate the number of days in a year without considering leap year scenarios. |
4-
| test.cpp:78:11:78:29 | __PRETTY_FUNCTION__ | There is an array allocation with a hard-coded set of 365 elements, which may indicate the number of days in a year without considering leap year scenarios. |

cpp/ql/test/query-tests/Likely Bugs/Leap Year/UnsafeArrayForDaysOfYear/test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,5 +75,5 @@ void f_______________________________________________________this_name_must_be_e
7575
// and `()`). in this case, this adds up to exactly 364 characters.
7676
// The initializer for `__PRETTY_FUNCTION__` thus initializes an array of
7777
// length 365 (because the null-terminator adds another character).
78-
auto x = __PRETTY_FUNCTION__; // $ SPURIOUS: Alert
78+
auto x = __PRETTY_FUNCTION__; // clean
7979
}

0 commit comments

Comments
 (0)