================
@@ -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}}
+}
----------------
NagyDonat wrote:

To me this result looks like a false positive (I'd guess that this `strlen` 
call is well-defined and returns 1, but I'm not familiar with the exact rules 
for C++ temp objects).

If this is indeed a false positive, then either fix it, or add a comment like 
"FIXME: In this corner case the checker produces a false positive".

If the report is a true positive, then perhaps explain why is it a true 
positive.

https://github.com/llvm/llvm-project/pull/113899
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to