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

LLVM Backend Assertion Failure when switching on union #4841

Open
MrMetube opened this issue Feb 13, 2025 · 0 comments
Open

LLVM Backend Assertion Failure when switching on union #4841

MrMetube opened this issue Feb 13, 2025 · 0 comments

Comments

@MrMetube
Copy link

Context

    Odin:    dev-2025-02:584fdc0d4
    OS:      Windows 11 Professional (version: 24H2), build 26100.3194
    CPU:     12th Gen Intel(R) Core(TM) i5-12600
    RAM:     32540 MiB
    Backend: LLVM 18.1.8

Current Behavior

The LLVM backend of the compiler crashes on an assertion, when type-asserting a union value in a ambiguous switch case.
It will not crash if we do not take a reference to the value.

package main

Foo :: union { int, bool }

main :: proc() {
    foo : Foo = true
    switch &v in foo {
    //     ^ If we don't take a reference its fine.
        case int, bool:
            _ = v.(int)
    }
}

Compiler Output

odin run .\repro.odin -file

C:\Odin\src\llvm_backend_general.cpp(1070): Assertion Failure: `is_type_pointer(value.type)` Foo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant