[clang] [clang][analyzer] Bring checker 'alpha.unix.cstring.NotNullTerminated' out of alpha (PR #113899)

Balázs Kéri via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 12 07:35:06 PST 2024


================
@@ -53,3 +53,7 @@ struct TestNotNullTerm {
     strlen((char *)&x); // expected-warning{{Argument to string length function is not a null-terminated string}}
   }
 };
+
+void test_notcstring_tempobject() {
+  strlen((char[]){'a', 0}); // expected-warning{{Argument to string length function is a C++ temp object of type char[2], which is not a null-terminated string}}
+}
----------------
balazske wrote:

This is taken from a FIXME in line 991 of the checker code. This exact case is really a false positive, a warning is needed only if a write happens into such a region. For this exact case (temporary object that behaves like a C string) the checker can be improved. But such a change would affect other checkers in the 'cstring' group.

https://github.com/llvm/llvm-project/pull/113899


More information about the cfe-commits mailing list