Skip to content

LLVM backend panic on #soa[dynamic]T / #soa[]T field-first index writes #6344

@k-nrd

Description

@k-nrd

Context

Odin: dev-2026-02-nightly
OS: CachyOS, Linux 6.19.3-2-cachyos
CPU: Intel(R) Xeon(R) CPU E5-2620 v3 @ 2.40GHz
RAM: 64136 MiB
Backend: LLVM 20.1.8

Expected Behavior

pool.x[i] = v and pool.x[i] += v should work on #soa[dynamic]T and #soa[]T, same as they do on fixed-size #soa[N]T.

Current Behavior

Compiler panics at all optimization levels:

src/llvm_backend_expr.cpp(2902): Panic: Invalid type conversion: 'f32' to '[^]f32'

Reads through pool.x[i] work. Writes and compound assignments crash. A workaround assigning local pointers like px := pool.x; px[i] = v works.

Failure Information

Steps to Reproduce

Build this at any optimization level:

package soa_repro
import "core:fmt"
Entity :: struct { x: f32, y: f32, vx: f32, vy: f32 }
main :: proc() {
    pool := make_soa(#soa[dynamic]Entity, 16, 64)
    defer delete_soa(pool)
    for i in 0 ..< 16 { pool[i] = Entity{f32(i), f32(i) * 2, 1, 2} }
    for i in 0 ..< 16 { pool.x[i] += pool.vx[i] }  // panic
    for i in 0 ..< 16 { fmt.printf("%v\n", pool[i].x) }
}
Pattern Read Write Compound
pool[i].x OK OK OK
pool.x[i] dynamic/slice OK CRASH CRASH
pool.x[i] fixed OK OK OK
px := pool.x; px[i] OK OK OK

Failure Logs

soa_repro::main
lb_emit_conv: src -> dst
Not Identical f32 != [^]f32
Not Identical f32 != [^]f32
Not Identical 70fc188 != 7fa42f308200
Not Identical 70fc188 != 7fa42f308200
src/llvm_backend_expr.cpp(2902): Panic: Invalid type conversion: 'f32' to '[^]f32' for procedure 'soa_repro::main'
/usr/sbin/bash: line 1: 26220 Illegal instruction        (core dumped) odin build /tmp/soa_issue_repro -o:none 2>&1

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions