[clang] [clang][sema] Add nonnull attribute to builtin format functions (PR #158626)
Erich Keane via cfe-commits
cfe-commits at lists.llvm.org
Mon Sep 15 11:04:40 PDT 2025
erichkeane wrote:
> I’m not sure it’s defined anywhere whether `nullptr` is a valid argument to `printf`, but if GCC diagnoses this then it should be fine for us to do so as well.
I agree with all you've said in the review.
Quite a few of the functions listed state that it is UB if they get passed 'nullptr' for the format string, but `printf`/`fprintf` don't do so explicitly (I only spot-checked). However, the entire standard section for `fprintf` (`printf` says "does what `fprintf` does, to `stdout`") seems to assume a valid format string, so I think this is reasonable.
I'm happy when you are.
https://github.com/llvm/llvm-project/pull/158626
More information about the cfe-commits
mailing list