Skip to content

Addressable loop variable causes stack overflow when it shouldn't for union types #5967

@atticus5

Description

@atticus5

Context

Odin dev-2025-11:e5153a937
macOS 15.6.1

Expected Behavior

switch &s in state.scene { should not throw a stack overflow warning

Current Behavior

test.odin(30:13) Warning: Declaration of 's' may cause a stack overflow due to its type 'SecondScene' having a size of 399999996 bytes
    switch &s in state.scene {

Steps to Reproduce


package test

SceneType :: enum {
    MAIN,
    SECONDARY,
}

Scene :: union {
    MainScene,
    SecondScene,
}

MainScene :: struct {
    data: [99999999]i32,
}

SecondScene :: struct {
    data: [99999999]i32,
}


GameState :: struct {
    scene: Scene,
}

main :: proc() {

    state := new(GameState)

    switch &s in state.scene {
    case MainScene:
    case SecondScene:
    }

}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions