-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Closed
Labels
bugObserved behavior contradicts documented or intended behaviorObserved behavior contradicts documented or intended behaviorstandard libraryThis issue involves writing Zig code for the standard library.This issue involves writing Zig code for the standard library.
Milestone
Description
Zig Version
0.12.0-dev.3381+7057bffc1
Steps to Reproduce and Observed Behavior
To reproduce run:
pub fn main() !void {
const olength: u32 = 1;
const precision: ?usize = null;
const exponent: i32 = -1;
const req_bytes = 2 + @max(@abs(exponent) + olength, precision orelse 0);
_ = req_bytes;
}❯ zig run test.zig
test.zig:5:25: error: overflow of integer type 'u2' with value '4'
const req_bytes = 2 + @max(@abs(exponent) + olength, precision orelse 0);
~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This is an actual library line:
Line 275 in e831313
| 2 + @max(@abs(f.exponent) + olength, precision orelse 0); |
It happens only in comptime
Expected Behavior
result type must be u32 or usize instead of u2
Metadata
Metadata
Assignees
Labels
bugObserved behavior contradicts documented or intended behaviorObserved behavior contradicts documented or intended behaviorstandard libraryThis issue involves writing Zig code for the standard library.This issue involves writing Zig code for the standard library.