You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: clang/test/Analysis/string.cpp
+7Lines changed: 7 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -53,3 +53,10 @@ struct TestNotNullTerm {
53
53
strlen((char *)&x); // expected-warning{{Argument to string length function is not a null-terminated string}}
54
54
}
55
55
};
56
+
57
+
voidtest_notcstring_tempobject() {
58
+
// FIXME: This warning from cstring.NotNullTerminated is a false positive.
59
+
// Handling of similar cases is not perfect in other cstring checkers.
60
+
// The fix would be a larger change in CStringChecker and affect multiple checkers.
61
+
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}}
strcpy(x, (char*)&strcpy_fn); // expected-warning{{Argument to string copy function is the address of the function 'strcpy_fn', which is not a null-terminated string}}
0 commit comments