zig icon indicating copy to clipboard operation
zig copied to clipboard

std.fmt incorrectly displaying vector of bools

Open Traxar opened this issue 1 year ago • 2 comments

Zig Version

0.13.0

Steps to Reproduce and Observed Behavior

const std = @import("std");

test {
    const ally = std.testing.allocator;
    const a: [*]bool = (try ally.alloc(bool,6)).ptr;
    defer ally.free(a[0..6]);
    a[1..][0..5].* = .{ false, false, false, false, false };
    const b: @Vector(5, bool) = a[0..][0..5].*;
    
    std.log.warn("b: {}", .{b});
    std.log.warn("b: {{ {}, {}, {}, {}, {} }}", .{b[0],b[1],b[2],b[3],b[4]});

    return error.PrintsDoNotMatch;
}

Log output:

[default] (warn): b: { false, true, false, true, false }
[default] (warn): b: { false, false, false, false, false }

Expected Behavior

I would expect the 2 log entries to match

Traxar avatar Jul 09 '24 19:07 Traxar

note: a[0] is undefined

AndrewKraevskii avatar Jul 12 '24 09:07 AndrewKraevskii

yes, I would still expect the prints to match, though

Traxar avatar Jul 12 '24 22:07 Traxar