Skip to content

x86_64 regression: @bitCast to bool vectors produces incorrect results #26008

@IntegratedQuantum

Description

@IntegratedQuantum

Zig Version

0.16.0-dev.1415+db622f14c (worked in 0.15.2)

Steps to Reproduce and Observed Behavior

Run the following Zig code that bitcasts a u3 to a bool vector:

const std = @import("std");

pub fn main() !void {
	var value: u3 = 7;
	_ = &value;
	std.log.err("{any}", .{@as(@Vector(3, bool), @bitCast(value))});
}

Observe how it produces false in newer versions with the x86_64 backend:

$ zig-debug run test.zig -fno-llvm
error: { false, false, false }

Expected Behavior

It should return true since all bits are set, this works in the llvm backend as well as the 0.15.2 x86_64 backend:

$ zig-debug run test.zig -fllvm
error: { true, true, true }
$ ~/Downloads/zig-x86_64-linux-0.15.2/zig run test.zig -fno-llvm
error: { true, true, true }

Metadata

Metadata

Assignees

No one assigned

    Labels

    arch-x86_6464-bit x86backend-self-hostedbugObserved behavior contradicts documented or intended behaviormiscompilationThe compiler reports success but produces semantically incorrect code.regressionIt worked in a previous version of Zig, but stopped working.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions