Skip to content

Can't format u32 values on i386 arch #5087

Closed
@fazibear

Description

@fazibear

Trying to compile:

const std = @import("std");

pub fn main() anyerror!void {
    var x:u32 = 123;
    
    std.debug.warn("test: {}", .{x});
}

with

    const target = b.standardTargetOptions(.{
        .default_target = .{
            .cpu_arch = .i386,
        },
    });

throws error:

/usr/local/Cellar/zig/0.6.0/lib/zig/std/debug.zig:1449:78: error: expected type 'usize', found 'u64'
                    .line_info = o_file_di.getLineNumberInfo(compile_unit.*, relocated_address_o) catch |err| switch (err) {
                                                                             ^
/usr/local/Cellar/zig/0.6.0/lib/zig/std/debug.zig:1449:78: note: unsigned 32-bit int cannot represent all possible unsigned 64-bit values
                    .line_info = o_file_di.getLineNumberInfo(compile_unit.*, relocated_address_o) catch |err| switch (err) {
                                                                             ^
/usr/local/Cellar/zig/0.6.0/lib/zig/std/debug.zig:578:25: note: referenced here
    const symbol_info = try module.getSymbolAtAddress(address);
                        ^
/usr/local/Cellar/zig/0.6.0/lib/zig/std/debug.zig:328:9: note: referenced here
        try printSourceAtAddress(debug_info, out_stream, return_address - 1, tty_config);
        ^
/usr/local/Cellar/zig/0.6.0/lib/zig/std/debug.zig:211:98: note: referenced here
    writeStackTrace(stack_trace, stderr, getDebugInfoAllocator(), debug_info, detectTTYConfig()) catch |err| {
                                                                                                 ^
/usr/local/Cellar/zig/0.6.0/lib/zig/std/debug.zig:228:14: error: unable to evaluate constant expression
    if (!ok) unreachable; // assertion failure
             ^
/usr/local/Cellar/zig/0.6.0/lib/zig/std/os/bits/darwin.zig:161:11: note: called from here
    assert(@byteOffsetOf(Kevent, "filter") == 8);
          ^
/usr/local/Cellar/zig/0.6.0/lib/zig/std/os/bits/darwin.zig:159:10: note: called from here
comptime {
         ^
/usr/local/Cellar/zig/0.6.0/lib/zig/std/os/bits/darwin.zig:161:11: note: referenced here
    assert(@byteOffsetOf(Kevent, "filter") == 8);
          ^

Is it a bug?

Metadata

Metadata

Assignees

No one assigned

    Labels

    arch-x8632-bit x86bugObserved behavior contradicts documented or intended behavioros-macosstandard libraryThis issue involves writing Zig code for the standard library.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions