Skip to content

Equality operator between ?T and T crashes the compiler #10283

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

Closed
yizhepku opened this issue Dec 6, 2021 · 1 comment
Closed

Equality operator between ?T and T crashes the compiler #10283

yizhepku opened this issue Dec 6, 2021 · 1 comment
Labels
bug Observed behavior contradicts documented or intended behavior

Comments

@yizhepku
Copy link

yizhepku commented Dec 6, 2021

Zig Version

zig trunk (on the compiler explorer)

Steps to Reproduce

Try to compile this code:

pub fn main() !void {
    var foo: i32 = 47;
    var bar: ?i32 = 47;
    if (foo == bar and true) {}
}

The and true part is essential to reproduce the bug.

Expected Behavior

It should compiles without error. I believe PR #5161 is supposed to implement this.

Actual Behavior

The compiler fails with the following error message:

broken LLVM module found: PHI node entries do not match predecessors!
  %9 = phi i1 [ %8, %Entry ], [ true, %BoolAndTrue ], !dbg !3697
label %BoolAndTrue
label %CmpOptionalNonOptionalEnd
Instruction does not dominate all uses!
  %8 = phi i1 [ false, %CmpOptionalNonOptionalOptionalNull ], [ %7, %CmpOptionalNonOptionalOptionalNotNull ], !dbg !3696
  %9 = phi i1 [ %8, %Entry ], [ true, %BoolAndTrue ], !dbg !3697

This is a bug in the Zig compiler.thread 1 panic: 
Unable to dump stack trace: debug info stripped
Compiler returned: 139

Demonstation: https://godbolt.org/z/fKExbr67M

@yizhepku yizhepku added the bug Observed behavior contradicts documented or intended behavior label Dec 6, 2021
@Vexu
Copy link
Member

Vexu commented Dec 6, 2021

Duplicate of #6059.

@Vexu Vexu closed this as completed Dec 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
Projects
None yet
Development

No branches or pull requests

2 participants