Skip to content

Commit f0de9c3

Browse files
committed
C++: Add a crazy false positive from a Microsoft internal issue.
1 parent 0780aca commit f0de9c3

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
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: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,12 @@ void VectorOfDays_FalsePositive(int dayOfYear, int x)
6868

6969
items[dayOfYear - 1] = x;
7070
}
71+
72+
void f_______________________________________________________this_name_must_be_exactly_357_chars__________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________() {
73+
// Using this magic compiler variable results in a `const char` array being
74+
// initialized with the function name which (including `void`, a space,
75+
// and `()`). in this case, this adds up to exactly 364 characters.
76+
// The initializer for `__PRETTY_FUNCTION__` thus initializes an array of
77+
// length 365 (because the null-terminator adds another character).
78+
auto x = __PRETTY_FUNCTION__; // $ SPURIOUS: Alert
79+
}

0 commit comments

Comments
 (0)