[clang] [Clang] Added clang diagnostic when snprintf/vsnprintf uses sizeof(de… (PR #170637)
Oliver Hunt via cfe-commits
cfe-commits at lists.llvm.org
Thu Jan 1 22:01:49 PST 2026
================
@@ -188,3 +188,12 @@ void strcpy_and_friends() {
strndup(FOO, sizeof(FOO)); // \
// expected-warning {{'strndup' call operates on objects of type 'const char' while the size is based on a different type 'const char *'}} expected-note{{did you mean to provide an explicit length?}}
}
+
+extern "C" int snprintf(char* buffer, __SIZE_TYPE__ buf_size, const char* format, ...);
+extern "C" void* malloc(unsigned size);
+
+void check_prints(){
----------------
ojhunt wrote:
Hooray! Paranoid testing for the win! :D
https://github.com/llvm/llvm-project/pull/170637
More information about the cfe-commits
mailing list