[libcxx-commits] [libcxx] [libc++] Fix broken precondition of __bit_log2 (PR #155476)

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Wed Sep 17 06:42:58 PDT 2025


ldionne wrote:

> Why do we need to cherry-pick this ASAP? What fallout is there? If the answer is "UBSan complains", I'm very much not happy, since that is exactly what I was complaining about - doing ad-hoc fixes without actually addressing the underlying problem, namely not having CI coverage.

In practice, yes the fallout is that UBSan is complaining (which crashes the program that runs it). Now, we have three options. We introduced a bug in our code and it introduced a regression in something our users were relying on. We can:
1. Ignore the problem until we have full support and CI coverage for `-fsanitize=unsigned-integer-overflow`, and then reapply the exact same fix I'm doing here (since it fixes a precondition). Opting for this approach would be taking the hard line and being rigid just for the sake of enforcing that everything we do is covered by CI, knowing full well that we have an underlying bug anyways (the broken precondition) and that we want to get said CI running in the future anyways. And in the meantime, our users would be broken. That is not a good option.
2. Revert the original refactoring patch that introduced the issue.
3. Apply this fix which resolves the issue, fixes the broken precondition and moves us forward.

Clearly, I think that either (2) or (3) are better pragmatic decisions, which is why I went for (3).

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


More information about the libcxx-commits mailing list