odin-lang / Odin

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

assigning a constant vector as an element in a global array can give an LLVM error #2834

Open bg-thompson opened 1 year ago

bg-thompson commented 1 year ago

Context

Odin: dev-2023-09:81fe9312
OS:   Windows 11 Home Basic (version: 22H2), build 22621.2283
CPU:  Intel(R) Core(TM) i5-10400F CPU @ 2.90GHz
RAM:  32689 MiB

Failure Information (for bugs)

Attempting to compile the following code

package bug
import "core:fmt"

V   :: [2]int{2,3}
fa2 : [2][2]int = V

main :: proc() {
    fa1 : [2][2]int = V 
    fmt.println(fa1) // Prints [[2,3],[2,3]]
    fmt.println(fa2) // LLVM Error when line not commented, compiles when commented. 
}

produces the following LLVM error:

LLVM Error:
Global variable initializer type does not match global variable type!
ptr @test.fa2

yet when the second-last line in the code is commented, the code compiles.

thetarnav commented 7 months ago

just hit the same issue

code

package bug

import "core:fmt"

VAL: [3]u8 : {1, 2, 3}
arr: [69][3]u8 = VAL

main :: proc() {
    fmt.println(arr)
}

output

LLVM Error:
Global variable initializer type does not match global variable type!
ptr @bug.arr

report

    Odin:    dev-2024-04:a14f0d8f5
    OS:      Ubuntu 22.04.4 LTS, Linux 6.5.0-27-generic
    CPU:     Intel(R) Core(TM) i5-8265U CPU @ 1.60GHz
    RAM:     7631 MiB
    Backend: LLVM 17.0.6