Skip to content
New issue

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

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

Already on GitHub? # to your account

x86_64 backend miscomp #20113

Open
Rexicon226 opened this issue May 29, 2024 · 0 comments
Open

x86_64 backend miscomp #20113

Rexicon226 opened this issue May 29, 2024 · 0 comments
Labels
arch-x86_64 64-bit x86 backend-self-hosted bug Observed behavior contradicts documented or intended behavior
Milestone

Comments

@Rexicon226
Copy link
Contributor

Zig Version

master

Steps to Reproduce and Observed Behavior

const std = @import("std");

const Data = packed struct {
    rd: u5,
    rl: bool,
};

pub const Operand = union(enum) {
    reg: enum {
        t0, // commenting this out fixes the issue
        s0,
    },
    barrier: enum(u4) {
        rl,
    },
};

pub fn main() !void {
    var rd: Operand = .{ .reg = .s0 };
    var rl: Operand = .{ .barrier = .rl };
    _ = &rd;
    _ = &rl;

    const ret: Data = .{
        .rd = @intFromEnum(rd.reg),
        .rl = rl.barrier == .rl,
    };

    std.debug.print("ret: {}, {}\n", .{ ret.rl, rl.barrier == .rl });
}

output:

ret: false, true

Expected Behavior

when commenting out the t0 enum and/or compiling with LLVM, expected output is:

ret: true, true
@Rexicon226 Rexicon226 added the bug Observed behavior contradicts documented or intended behavior label May 29, 2024
@Vexu Vexu added this to the 0.14.0 milestone May 29, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
arch-x86_64 64-bit x86 backend-self-hosted bug Observed behavior contradicts documented or intended behavior
Projects
None yet
Development

No branches or pull requests

2 participants