- Miscompilation: global struct with vector could generate an incorrect initializer.

This commit is contained in:
Christoffer Lerno
2025-12-30 23:54:00 +01:00
parent ad8769580a
commit d8a7c57b56
3 changed files with 36 additions and 14 deletions

View File

@@ -0,0 +1,22 @@
// #target: macos-x64
module test;
struct Struct
{
float[<3>] foo;
int bar;
}
Struct my_struct1 = { .foo[1] = 1.0, .bar = 10 };
Struct my_struct2 = { .bar = 10 };
fn int main()
{
return my_struct1.bar + my_struct2.bar;
}
/* #expect: test.ll
@test.my_struct1 = local_unnamed_addr global { [3 x float], i32 } { [3 x float] [float 0.000000e+00, float 1.000000e+00, float 0.000000e+00], i32 10 }, align 4
@test.my_struct2 = local_unnamed_addr global { [3 x float], i32 } { [3 x float] zeroinitializer, i32 10 }, align 4