29 lines
711 B
Plaintext
29 lines
711 B
Plaintext
// issue-0015: Global array variables with initializers contain all zeros at runtime.
|
|
//
|
|
// Expected: VALS[0]=-2, VALS[1]=-1, VALS[2]=42
|
|
// Actual: VALS[0]=0, VALS[1]=0, VALS[2]=0
|
|
//
|
|
// Global arrays declared with `: [N]T = .[...]` syntax get zero-initialized
|
|
// instead of receiving their specified values.
|
|
|
|
#import "modules/std.sx";
|
|
|
|
VALS : [4]s32 = .[-2, -1, 42, 99];
|
|
|
|
main :: () {
|
|
out("VALS: ");
|
|
i := 0;
|
|
while i < 4 {
|
|
out(int_to_string(xx VALS[i]));
|
|
out(" ");
|
|
i = i + 1;
|
|
}
|
|
out("\n");
|
|
|
|
if VALS[0] == -2 and VALS[1] == -1 and VALS[2] == 42 and VALS[3] == 99 {
|
|
out("PASS\n");
|
|
} else {
|
|
out("FAIL: global array not initialized\n");
|
|
}
|
|
}
|