-
Notifications
You must be signed in to change notification settings - Fork 61
Open
Labels
Description
Given the following example
PROGRAM mainProg
VAR
incorrect : ARRAY[0..1] OF STRUCT2 := [(x1 := TRUE, x2 := 128, x3 := 12, x4 := 421)]; // wrong initializer
correct : ARRAY[0..1] OF STRUCT2 := [(x1 := TRUE, x2 := 128), (x1 := TRUE, x2 := 128)]; // correct initializer
END_VAR
END_PROGRAM
TYPE STRUCT2 :
STRUCT
x1 : BOOL;
x2 : DINT;
x3 : DINT;
x4 : DINT;
END_STRUCT
END_TYPE
our generated IR differs significantly between the two variables. Here is what we generate, when multiple (at least 2) array members are specified:
llvm_value: "[2 x %STRUCT2] [%STRUCT2 { i8 1, i32 128, i32 0, i32 0 }, %STRUCT2 { i8 1, i32 128, i32 0, i32 0 }]",
This is what happens if we only specify 1 element:
llvm_value: "[4 x %STRUCT2] [%STRUCT2 { i8 1, i32 0, i32 0, i32 0 }, %STRUCT2 { i8 0, i32 128, i32 0, i32 0 }, %STRUCT2 { i8 0, i32 0, i32 12, i32 0 }, %STRUCT2 { i8 0, i32 0, i32 0, i32 421 }]",
Not only is the single element no longer initialized as we'd expect, the llvm array value now also magically has a length of 4 instead of the declared length of 2.
Metadata
Metadata
Assignees
Labels
Type
Projects
Milestone
Relationships
Development
Select code repository
Activity