diff --git a/cpp/ql/src/Likely Bugs/Leap Year/UnsafeArrayForDaysOfYear.ql b/cpp/ql/src/Likely Bugs/Leap Year/UnsafeArrayForDaysOfYear.ql index b27db937b577..e6b1ccaa6687 100644 --- a/cpp/ql/src/Likely Bugs/Leap Year/UnsafeArrayForDaysOfYear.ql +++ b/cpp/ql/src/Likely Bugs/Leap Year/UnsafeArrayForDaysOfYear.ql @@ -26,6 +26,7 @@ where or exists(Variable var | var = element and + not var.isCompilerGenerated() and var.getType() instanceof LeapYearUnsafeDaysOfTheYearArrayType and allocType = "an array allocation" ) diff --git a/cpp/ql/src/change-notes/2026-08-28-leap-year-unsafe-array-fp.md b/cpp/ql/src/change-notes/2026-08-28-leap-year-unsafe-array-fp.md new file mode 100644 index 000000000000..4ba04f0de358 --- /dev/null +++ b/cpp/ql/src/change-notes/2026-08-28-leap-year-unsafe-array-fp.md @@ -0,0 +1,4 @@ +--- +category: minorAnalysis +--- +* The `cpp/leap-year/unsafe-array-for-days-of-the-year` query ("Unsafe array for days of the year") no longer reports an alert on the `__PRETTY_FUNCTION__` variable (and related variables) when the enclosing function has a signature that is exactly 364 characters. \ No newline at end of file diff --git a/cpp/ql/test/query-tests/Likely Bugs/Leap Year/UnsafeArrayForDaysOfYear/test.cpp b/cpp/ql/test/query-tests/Likely Bugs/Leap Year/UnsafeArrayForDaysOfYear/test.cpp index f76167c1893b..3994fce4ee88 100644 --- a/cpp/ql/test/query-tests/Likely Bugs/Leap Year/UnsafeArrayForDaysOfYear/test.cpp +++ b/cpp/ql/test/query-tests/Likely Bugs/Leap Year/UnsafeArrayForDaysOfYear/test.cpp @@ -68,3 +68,12 @@ void VectorOfDays_FalsePositive(int dayOfYear, int x) items[dayOfYear - 1] = x; } + +void f_______________________________________________________this_name_must_be_exactly_357_chars__________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________() { + // Using this magic compiler variable results in a `const char` array being + // initialized with the function signature. Including `void`, a space, and + // `()`, the signature adds up to exactly 364 characters in this case. + // The initializer for `__PRETTY_FUNCTION__` thus initializes an array of + // length 365 (because the null-terminator adds another character). + auto x = __PRETTY_FUNCTION__; // clean +} \ No newline at end of file