Skip to content

Trying to cast a pointer of a union value to rawptr causes crash when switching on multiple cases #4803

Closed
@Binasaurus-Hex

Description

@Binasaurus-Hex

Context

    Odin:    dev-2024-09-nightly:dd1f151
    OS:      Windows 10 Home Basic (version: 22H2), build 19045.5371
    CPU:     AMD Ryzen 5 3600 6-Core Processor
    RAM:     16333 MiB
    Backend: LLVM 18.1.8 

Code

package bugs
main :: proc(){
	a : union {int, f32, [2]f32 }
	switch &v in a {
		case int, f32:
			pointer :rawptr = &v
		case [2]f32:
	}
}

Expected Behavior

the compiler either gets the correct pointer of the value, or gives an error saying "cannot take adress of multiple value switch"

Current Behavior

compiler crashes

Failure Information

bugs.main lb_emit_conv: src -> dst Not Identical union {int, f32, [2]f32} != rawptr Not Identical union {int, f32, [2]f32} != rawptr Not Identical 1af99d5b630 != 7ff6bd23b6e8 Not Identical 1af99d5b630 != 7ff6bd23b6e8 D:\a\Odin\Odin\src\llvm_backend_expr.cpp(2478): Panic: Invalid type conversion: 'union {int, f32, [2]f32}' to 'rawptr' for procedure 'bugs.main'

Steps to Reproduce

run the provided code in a fresh odin project

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions