================ @@ -96,6 +96,11 @@ void call_snprintf(double d) { __builtin_snprintf(buf, 1, "%.1000g", d); // expected-warning {{'snprintf' will always be truncated; specified size is 1, but format string expands to at least 2}} __builtin_snprintf(buf, 5, "%.1000g", d); __builtin_snprintf(buf, 5, "%.1000G", d); + char node_name[6]; + __builtin_snprintf(node_name, sizeof(node_name), "%pOFn", ptr); + __builtin_snprintf(node_name, sizeof(node_name), "12345%pOFn", ptr); + __builtin_snprintf(node_name, sizeof(node_name), "123456%pOFn", ptr); // expected-warning {{'snprintf' will always be truncated; specified size is 6, but format string expands to at least 7}} ---------------- hazohelet wrote:
GCC doesn't warn on this ([live demo](https://godbolt.org/z/bEbYx5Gar)). It's probably because GCC even ignores the terminating null char, but I think it makes sense to consider the null char and add 1 (Probably it doesn't matter much, though). https://github.com/llvm/llvm-project/pull/65969 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits