Louis Dionne
0bbb936729
[libc++] Fix broken precondition of __bit_log2 ( #155476 )
...
In #135303 , we started using `__bit_log2` instead of `__log2i` inside
`std::sort`. However, `__bit_log2` has a precondition that `__log2i`
didn't have, which is that the input is non-zero. While it technically
makes no sense to request the logarithm of 0, `__log2i` handled that
case and returned 0 without issues.
After switching to `__bit_log2`, passing 0 as an input results in an
unsigned integer overflow which can trigger
`-fsanitize=unsigned-integer-overflow`. While not technically UB in
itself, it's clearly not intended either.
To fix this, we add an internal assertion to `__bit_log2` which catches
the issue in our test suite, and we make sure not to violate
`__bit_log2`'s preconditions before we call it from `std::sort`.
(cherry picked from commit 2ae4b92a1cf01b7d09f70ccc919eca2b5d02b080)
2025-09-09 10:33:32 +02:00
..
2024-12-18 21:10:27 +01:00
2024-11-06 12:10:06 +01:00
2024-11-06 12:10:06 +01:00
2024-12-18 21:10:27 +01:00
2025-01-08 11:12:59 -05:00
2024-10-30 11:51:55 +01:00
2025-03-19 11:58:02 -04:00
2024-11-06 12:10:06 +01:00
2024-11-12 23:03:52 +01:00
2025-03-19 11:55:51 -04:00
2024-11-06 12:10:06 +01:00
2025-03-19 11:36:29 -04:00
2024-12-18 21:10:27 +01:00
2025-03-19 11:51:21 -04:00
2025-02-05 11:39:49 -05:00
2024-12-18 21:10:27 +01:00
2024-12-18 21:10:27 +01:00
2024-09-12 21:18:43 +02:00
2024-09-12 21:18:43 +02:00
2025-03-13 14:15:03 -04:00
2025-05-21 12:10:50 -04:00
2025-06-18 12:22:47 -04:00
2025-06-18 12:22:47 -04:00
2024-12-18 21:10:27 +01:00
2025-03-19 07:42:23 +08:00
2024-09-12 21:18:43 +02:00
2024-12-18 21:10:27 +01:00
2024-09-12 21:18:43 +02:00
2024-12-18 21:10:27 +01:00
2024-12-18 21:10:27 +01:00
2024-12-18 21:10:27 +01:00
2025-01-08 11:12:59 -05:00
2024-11-06 10:39:19 +01:00
2024-12-18 21:10:27 +01:00
2025-01-20 18:00:15 +01:00
2024-09-12 21:18:43 +02:00
2024-09-12 21:18:43 +02:00
2024-12-18 21:10:27 +01:00
2025-03-27 09:05:37 -04:00
2024-09-12 21:18:43 +02:00
2024-09-16 15:06:20 -04:00
2024-09-12 21:18:43 +02:00
2025-01-08 18:14:39 +01:00
2025-02-19 11:36:45 -05:00
2025-02-19 11:36:45 -05:00
2024-09-12 21:18:43 +02:00
2025-04-05 13:46:11 +02:00
2024-09-16 15:06:20 -04:00
2024-09-16 15:06:20 -04:00
2025-01-24 09:34:42 +01:00
2025-04-16 17:34:11 +08:00
2024-11-06 12:10:06 +01:00
2024-11-06 12:10:06 +01:00
2024-11-06 12:10:06 +01:00
2024-08-01 08:54:06 -04:00
2024-08-01 08:54:06 -04:00
2024-08-01 08:54:06 -04:00
2024-08-01 08:54:06 -04:00
2024-08-01 08:54:06 -04:00
2024-11-06 12:10:06 +01:00
2024-11-12 23:03:52 +01:00
2024-11-12 23:03:52 +01:00
2024-11-06 12:10:06 +01:00
2024-08-01 08:54:06 -04:00
2024-09-16 15:06:20 -04:00
2024-08-01 08:54:06 -04:00
2024-08-01 08:54:06 -04:00
2024-11-06 12:10:06 +01:00
2024-08-01 08:54:06 -04:00
2024-08-01 08:54:06 -04:00
2024-08-01 08:54:06 -04:00
2024-08-01 08:54:06 -04:00
2024-08-01 08:54:06 -04:00
2024-09-16 15:06:20 -04:00
2024-08-01 08:54:06 -04:00
2024-09-30 08:30:16 -04:00
2025-06-18 12:22:47 -04:00
2025-06-18 12:22:47 -04:00
2024-09-16 15:06:20 -04:00
2024-09-16 15:06:20 -04:00
2024-08-01 08:54:06 -04:00
2025-03-20 01:59:32 +08:00
2024-08-01 08:54:06 -04:00
2024-08-01 08:54:06 -04:00
2024-08-01 08:54:06 -04:00
2024-08-01 08:54:06 -04:00
2024-08-01 08:54:06 -04:00
2024-08-01 08:54:06 -04:00
2025-02-21 07:59:46 -05:00
2024-08-04 10:02:43 +02:00
2024-08-01 08:54:06 -04:00
2024-08-01 08:54:06 -04:00
2025-03-27 09:05:37 -04:00
2025-03-27 09:05:37 -04:00
2024-08-01 08:54:06 -04:00
2025-03-27 09:05:37 -04:00
2025-03-27 09:05:37 -04:00
2024-08-01 08:54:06 -04:00
2024-10-30 11:51:55 +01:00
2024-08-01 08:54:06 -04:00
2024-08-01 08:54:06 -04:00
2024-08-01 08:54:06 -04:00
2024-08-01 08:54:06 -04:00
2024-08-01 08:54:06 -04:00
2024-08-01 08:54:06 -04:00
2024-08-01 08:54:06 -04:00
2024-08-01 08:54:06 -04:00
2024-08-01 08:54:06 -04:00
2024-08-01 08:54:06 -04:00
2024-09-16 15:06:20 -04:00
2024-08-01 08:54:06 -04:00
2024-08-01 08:54:06 -04:00
2024-08-01 08:54:06 -04:00
2024-08-01 08:54:06 -04:00
2024-08-01 08:54:06 -04:00
2024-08-01 08:54:06 -04:00
2024-08-01 08:54:06 -04:00
2024-08-01 08:54:06 -04:00
2024-08-01 08:54:06 -04:00
2024-08-01 08:54:06 -04:00
2024-08-01 08:54:06 -04:00
2024-08-01 08:54:06 -04:00
2024-08-01 08:54:06 -04:00
2024-08-01 08:54:06 -04:00
2024-08-01 08:54:06 -04:00
2024-08-01 08:54:06 -04:00
2024-08-01 08:54:06 -04:00
2024-08-01 08:54:06 -04:00
2024-11-12 23:03:52 +01:00
2024-08-01 08:54:06 -04:00
2024-11-12 23:03:52 +01:00
2024-11-12 23:03:52 +01:00
2024-08-01 08:54:06 -04:00
2024-08-01 08:54:06 -04:00
2024-08-01 08:54:06 -04:00
2025-03-06 09:23:55 +08:00
2025-03-07 01:27:48 +08:00
2024-08-01 08:54:06 -04:00
2024-08-01 08:54:06 -04:00
2024-08-01 08:54:06 -04:00
2025-01-08 11:12:59 -05:00
2024-08-01 08:54:06 -04:00
2024-08-01 08:54:06 -04:00
2024-09-12 21:18:43 +02:00
2024-09-12 21:18:43 +02:00
2025-03-13 14:07:23 -04:00
2024-09-16 15:06:20 -04:00
2024-09-16 15:06:20 -04:00
2024-11-12 23:03:52 +01:00
2024-09-16 15:06:20 -04:00
2024-11-12 23:03:52 +01:00
2024-11-12 23:03:52 +01:00
2025-05-28 12:04:51 -04:00
2025-03-24 13:22:40 -04:00
2025-09-09 10:33:32 +02:00
2025-03-04 09:23:29 +08:00
2025-04-16 17:34:11 +08:00
2025-03-04 17:15:36 -05:00
2025-01-08 11:12:59 -05:00
2024-09-16 15:06:20 -04:00
2024-11-06 12:10:06 +01:00
2025-01-08 11:12:59 -05:00
2024-09-16 15:06:20 -04:00