[clang] [clang][sema] Add nonnull attribute to builtin format functions (PR #160988)

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Wed Nov 5 04:48:23 PST 2025


Radovan =?utf-8?q?Božić?= <radovan.bozic at htecgroup.com>,
Radovan =?utf-8?q?Božić?= <radovan.bozic at htecgroup.com>,
Radovan =?utf-8?q?Božić?= <radovan.bozic at htecgroup.com>
Message-ID:
In-Reply-To: <llvm.org/llvm/llvm-project/pull/160988 at github.com>


AaronBallman wrote:

> @AaronBallman I don't think [#158626 (review)](https://github.com/llvm/llvm-project/pull/158626#pullrequestreview-3229443611) has really been addressed yet.

Thanks for raising the concern!

> If you think it's fine to basically undefine the behaviour of implementations that's fine with me, but I think we should acknowledge that we do that.

The behavior is undefined according to the standard, so this is 1) ensuring we get diagnostics for misuse, 2) improving optimization behavior. So it's not really the implementation undefining the behavior, it's the implementation admitting the behavior was already undefined (maybe too find of a distinction?).

gcc seems to treat the parameters as being marked nonnull: https://godbolt.org/z/YTb1ejh8W


https://github.com/llvm/llvm-project/pull/160988


More information about the cfe-commits mailing list