-
-
Notifications
You must be signed in to change notification settings - Fork 905
Open
Description
Context
Odin: dev-2026-02:b942f72cb
OS: macOS Ventura 13.7.8 (build 22H730, kernel 22.6.0)
CPU: Intel(R) Core(TM) i7-4750HQ CPU @ 2.00GHz
RAM: 8192 MiB
Backend: LLVM 21.1.8
Expected Behavior
Generate instructions to recursively chase the pointers or_else fail to compile.
Current Behavior
When nesting 2+ levels of pointer with subtype polymorphism, passing the top-level pointer to a procedure expecting the deep-nested type fails to perform the necessary dereferences. It instead passes the base pointer as if it were the target type.
Failure Information (for bugs)
a.b == a~>b: One level of indirection & artibrarily nesting POD subtype polymorphism works fine.a.b.c != a~>c; a == a~>c: Two+ levels of indirection implicitly transmutes the top-level pointer to the target type, causing invalid memory addresses and bad news.
Steps to Reproduce
import "core:fmt"
A :: struct {using b: ^B}
B :: struct {using c: ^C}
C :: struct {i: i64}
pass_a_as_b :: proc(b: ^B) {
fmt.printfln("a~~>b: %p", b)
}
pass_a_as_c :: proc(c: ^C) {
fmt.printfln("a~~>c: %p", c)
fmt.printfln(" c.i: {}", c.i)
}
main :: proc() {
a: ^A = new(A)
a.b = new(B)
a.b.c = new(C)
a.b.c.i = 123
fmt.printfln("a.b.c: %p", a.b.c)
fmt.printfln(" a.b: %p", a.b)
fmt.printfln(" a: %p", a)
pass_a_as_b(a)
pass_a_as_c(a)
}Failure Logs
a.b.c: 0x1004042C8
a.b: 0x1004042A8
a: 0x100404288
a~~>b: 0x1004042A8
a~~>c: 0x100404288
c.i: 4299178664
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels