Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reached unreachable code in digitToChar function. #22533

Open
KeithBrown39423 opened this issue Jan 18, 2025 · 0 comments
Open

Reached unreachable code in digitToChar function. #22533

KeithBrown39423 opened this issue Jan 18, 2025 · 0 comments
Labels
bug Observed behavior contradicts documented or intended behavior

Comments

@KeithBrown39423
Copy link

KeithBrown39423 commented Jan 18, 2025

Zig Version

0.13.0

Steps to Reproduce and Observed Behavior

To reproduce this, call the std.fmt.digitToChar function with a value that is higher than 36.

Example code

const std = @import("std");

pub fn main() !void {
    const c = std.fmt.digitToChar(89, .upper);
    std.debug.print("{}", .{c});
}
thread 5932 panic: reached unreachable code
C:\Users\keith\.zvm\0.13.0\lib\std\fmt.zig:1766:17: 0x3c10dd in digitToChar (zig-testing.exe.obj)
        else => unreachable,
                ^
C:\Users\keith\OneDrive\Documents\projects\zig-testing\src\main.zig:4:34: 0x3c1018 in main (zig-testing.exe.obj)
    const c = std.fmt.digitToChar(89, .upper);
                                 ^
C:\Users\keith\.zvm\0.13.0\lib\std\start.zig:363:53: 0x3c1391 in WinStartup (zig-testing.exe.obj)
    std.os.windows.ntdll.RtlExitUserProcess(callMain());
                                                    ^
???:?:?: 0x7ffbb544e8d6 in ??? (KERNEL32.DLL)
???:?:?: 0x7ffbb63ffbcb in ??? (ntdll.dll)

Expected Behavior

Technically, this works as expected, but in reality it should return an invalid parameter error.

@KeithBrown39423 KeithBrown39423 added the bug Observed behavior contradicts documented or intended behavior label Jan 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Observed behavior contradicts documented or intended behavior
Projects
None yet
Development

No branches or pull requests

1 participant