[clang] [clang] Implement -fstrict-bool (PR #160790)

via cfe-commits cfe-commits at lists.llvm.org
Mon Dec 1 09:49:00 PST 2025


=?utf-8?q?Félix?= Cloutier <fcloutier at apple.com>,
=?utf-8?q?Félix?= Cloutier <fcloutier at apple.com>,
=?utf-8?q?Félix?= Cloutier <fcloutier at apple.com>
Message-ID:
In-Reply-To: <llvm.org/llvm/llvm-project/pull/160790 at github.com>


apple-fcloutier wrote:

@erichkeane, Aaron was able to [weigh in](https://discourse.llvm.org/t/defining-what-happens-when-a-bool-isn-t-0-or-1/86778/41) last week and accept the change on behalf of the Clang area team. His feedback (to wrap up over here instead of on the RFC thread) is:

* the default should not change based on the target (that's OK, we don't change the default based on the target yet, it was just a possibility)
* the default should maybe be `nonzero` instead of truncate

I don't know who else has opinions here. The default behavior at -O0 today is `truncate` (Clang does not assume bool is only 0 or 1 in -O0 builds) and I feel that if we make the default `nonzero`, we should also change the -O0 behavior. Out of an aversion for risk, I am inclined to prefer `truncate` as the default. @pinskia, are there any considerations on the gcc side of things?

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


More information about the cfe-commits mailing list