Skip to content

Broadcasting a constant struct hits an assert in the llvm backend #5140

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

Closed
leecommamichael opened this issue May 9, 2025 · 2 comments
Closed

Comments

@leecommamichael
Copy link
Contributor

leecommamichael commented May 9, 2025

Context

    Odin:    dev-2025-05:e3fe733a5
    OS:      Windows 11 Home Basic (version: 24H2), build 26100.3775
    CPU:     AMD Ryzen 7 7700 8-Core Processor
    RAM:     15447 MiB
    Backend: LLVM 20.1.0

Failure Information (for bugs)

llvm_backend_const.cpp(918): Assertion Failure: elem_count == type->Array.count 1 != 2

Steps to Reproduce

INT :: struct { i: int }
ONE : Int: {1}
data: [2][2]Int = { ONE, { {4}, {5},} }

or

Int :: struct { i: int }
ONE: Int : {1} 
no_bro( { ONE, { {4}, {5},} } )
no_bro :: proc (#no_broadcast structs: [2][2]Int) {}

Please provide detailed steps for reproducing the issue.

odin run . with either snippet above.

Failure Logs

llvm_backend_const.cpp(918): Assertion Failure: elem_count == type->Array.count 1 != 2

Talked with @Kelimion on Discord here: https://discord.com/channels/568138951836172421/568146055409958913/1370504300953862155
Kelimion supposes the checker really ought to consider it an error to use Array Programming features with non-numerics.

@leecommamichael
Copy link
Contributor Author

package scratch

import "core:fmt"

String :: distinct string
ONE : String : "1"

main :: proc() {
    data: [2][2]String = { ONE, {"4", "5"}}
    fmt.println(data)
}

Yields
W:\Odin\src\llvm_backend_const.cpp(93): Assertion Failure: lb_sizeof(dst) == lb_sizeof(src) [2 x %..string] vs %..string = type { ptr, i64 }

@leecommamichael
Copy link
Contributor Author

duplicate of #5141

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

No branches or pull requests

1 participant