Skip to content
This repository was archived by the owner on May 18, 2019. It is now read-only.

Commit 2fee2f0

Browse files
perostOpenModelica-Hudson
authored andcommitted
Fix code generation for function outputs.
- Fix code generation for array output function parameters with literal default values. Such outputs were previously set to be equal to the shared literal, which caused a segfault if the array was then assigned to. This fix makes sure that a new array is created from the literal instead. Belonging to [master]: - #2917
1 parent 4b0bcc2 commit 2fee2f0

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

Compiler/Template/CodegenCFunctions.tpl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1908,6 +1908,10 @@ case var as VARIABLE(__) then
19081908
<%preExp%>
19091909
<%params%>
19101910
>>
1911+
// Treat shared array literals like other arrays, i.e. copy them. Array
1912+
// outputs in functions might otherwise end up pointing to shared literals,
1913+
// causing a segfault if such an array is then assigned to.
1914+
case SOME(arr as SHARED_LITERAL(__))
19111915
case SOME(arr as ARRAY(__)) then
19121916
let arrayExp = '<%daeExp(arr, contextFunction, &varInits, &varDecls, &auxFunction)%>'
19131917
'copy_<%expTypeShort(var.ty)%>_array(<%arrayExp%>, &<%lhsVarName%>);<%\n%>'

0 commit comments

Comments
 (0)