odin-lang / Odin

Odin Programming Language
https://odin-lang.org
BSD 3-Clause "New" or "Revised" License
6.59k stars 575 forks source link

Compiler panic: Invalid type conversion ^A to #relative(u16) ^A #3338

Open FourteenBrush opened 5 months ago

FourteenBrush commented 5 months ago

Context

I get a compiler panic on the following code:

package something

main :: proc() {
    Ptr :: struct($T: typeid) {
        ptr: #relative(u16) ^T,
    }

    A :: struct {}
    a := A {}
    ptr := Ptr(A) { ptr = &a }
}

Note that this happens with every backing size of the relative pointer. Compiler output:

something.main
lb_emit_conv: src -> dst
Not Identical ^A != #relative(u16) ^A
Not Identical ^A != #relative(u16) ^A
Not Identical 7e0d0b9f4050 != 7e0d4ca0ddd0
Not Identical 7e0d0b9f4050 != 7e0d4ca0ddd0
src/llvm_backend_expr.cpp(2291): Panic: Invalid type conversion: '^A' to '#relative(u16) ^A' for procedure 'something.main'

Operating System & Odin Version

Odin: dev-2024-03:63d6b4752 OS: Pop!_OS 22.04 LTS, Linux 6.8.0-76060800daily20240311-generic CPU: AMD Ryzen 7 5800H with Radeon Graphics
RAM: 13827 MiB Backend: LLVM 14.0.0

Expected Behavior

This should compile fine?

Steps to Reproduce

Simply run above file with odin run something.odin -file

FourteenBrush commented 4 months ago

I assume this is probably not getting fixed due to core:relative being a thing?