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

stage2: undefined Value generated from enum value (crash) #9804

Closed
g-w1 opened this issue Sep 20, 2021 · 1 comment
Closed

stage2: undefined Value generated from enum value (crash) #9804

g-w1 opened this issue Sep 20, 2021 · 1 comment
Labels
bug Observed behavior contradicts documented or intended behavior frontend Tokenization, parsing, AstGen, Sema, and Liveness.
Milestone

Comments

@g-w1
Copy link
Contributor

g-w1 commented Sep 20, 2021

This code generates an undefined (0xaaaaa) Value:

pub fn main() void {
    syscall0(SYS.EXITS);
}

fn syscall0(arg: SYS) void {
    _ = arg;
}

const SYS = enum(u32) {
    BAD = 1,
    EXITS = 8,
};
/home/jacob/dev/zig/src/value.zig:899:21: 0xa64c66 in value.Value.toUnsignedInt (zig1)
            else => unreachable,
                    ^
/home/jacob/dev/zig/src/codegen.zig:4921:79: 0x118c5cd in codegen.Function(std.target.Arch.x86_64).genTypedValue (zig1)
                    return MCValue{ .immediate = typed_value.val.toUnsignedInt() };
                                                                              ^
/home/jacob/dev/zig/src/codegen.zig:4953:62: 0x118d15d in codegen.Function(std.target.Arch.x86_64).genTypedValue (zig1)
                                    return self.genTypedValue(.{ .ty = enum_full.tag_ty, .val = tag_val });
                                                             ^
/home/jacob/dev/zig/src/codegen.zig:4823:65: 0x1189cb1 in codegen.Function(std.target.Arch.x86_64).resolveInst (zig1)
                        gop.value_ptr.* = try self.genTypedValue(.{
                                                                ^
/home/jacob/dev/zig/src/codegen.zig:2583:65: 0xfb2c17 in codegen.Function(std.target.Arch.x86_64).airCall (zig1)
                            const arg_mcv = try self.resolveInst(args[arg_i]);
                                                                ^
/home/jacob/dev/zig/src/codegen.zig:837:57: 0xfaa086 in codegen.Function(std.target.Arch.x86_64).genBody (zig1)
                    .call            => try self.airCall(inst),
                                                        ^
@g-w1 g-w1 changed the title stage2: undefined value generated from enum value stage2: undefined Value generated from enum value (crash) Sep 20, 2021
@Vexu Vexu added bug Observed behavior contradicts documented or intended behavior frontend Tokenization, parsing, AstGen, Sema, and Liveness. labels Sep 20, 2021
@Vexu Vexu added this to the 0.9.0 milestone Sep 20, 2021
@g-w1
Copy link
Contributor Author

g-w1 commented Oct 6, 2021

Fixed by e16ddad

@g-w1 g-w1 closed this as completed Oct 6, 2021
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 frontend Tokenization, parsing, AstGen, Sema, and Liveness.
Projects
None yet
Development

No branches or pull requests

2 participants