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

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

Open
Binasaurus-Hex opened this issue Feb 7, 2025 · 0 comments

Comments

@Binasaurus-Hex
Copy link

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

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

No branches or pull requests

2 participants