diff options
| author | Guillaume Wenzek <gwenzek@users.noreply.github.com> | 2024-01-12 17:28:56 +0100 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2024-01-13 18:46:16 -0800 |
| commit | c5d359e4cdcc6090f0ff1803adb929247027e7cb (patch) | |
| tree | 637055ee759a05603fad17d3cced1c1fdb84e0d7 /lib/std/math.zig | |
| parent | d55d1e32b65dd829cec17b5c5d65db10608d097c (diff) | |
| download | zig-c5d359e4cdcc6090f0ff1803adb929247027e7cb.tar.gz zig-c5d359e4cdcc6090f0ff1803adb929247027e7cb.zip | |
fix #17142, wrong comptime log_int computation
Diffstat (limited to 'lib/std/math.zig')
| -rw-r--r-- | lib/std/math.zig | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/lib/std/math.zig b/lib/std/math.zig index 47ae755da0..33b4245b6b 100644 --- a/lib/std/math.zig +++ b/lib/std/math.zig @@ -672,6 +672,7 @@ test "rotl" { /// - 1. Suitable for 0-based bit indices of T. pub fn Log2Int(comptime T: type) type { // comptime ceil log2 + if (T == comptime_int) return comptime_int; comptime var count = 0; comptime var s = @typeInfo(T).Int.bits - 1; inline while (s != 0) : (s >>= 1) { @@ -684,6 +685,7 @@ pub fn Log2Int(comptime T: type) type { /// Returns an unsigned int type that can hold the number of bits in T. pub fn Log2IntCeil(comptime T: type) type { // comptime ceil log2 + if (T == comptime_int) return comptime_int; comptime var count = 0; comptime var s = @typeInfo(T).Int.bits; inline while (s != 0) : (s >>= 1) { |
