[llvm-branch-commits] [libcxx] release/21.x: [libc++] Fix broken precondition of __bit_log2 (#155476) (PR #155932)

Louis Dionne via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Fri Sep 5 05:49:27 PDT 2025


ldionne wrote:

> I'd really like to know what the "fallout" here is before we merge something into a release branch that has perfectly defined behaviour.

The fallout is that some people are running with `-fsanitize=unsigned-integer-overflow` and that started breaking. In our case, some folks were even running with that sanitizer in production and that caused runtime issues.

I disagree that this has perfectly well defined behavior. That's a pedantic way to view things. We all agree that `log(0)` is undefined, and in fact our call to `log(0)` returned something that made no sense. The code only happened to work because we were then ignoring that invalid result due to other conditions (`first == last` inside `__introsort`).

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


More information about the llvm-branch-commits mailing list