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

Commit 51e9b19

Browse files
niklworsOpenModelica-Hudson
authored andcommitted
[cppruntime] fixed division by zero during setting start values
Belonging to [master]: - #2619
1 parent 9499275 commit 51e9b19

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

Compiler/Template/CodegenCppCommon.tpl

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2287,7 +2287,19 @@ template daeExpBinary(Operator it, Exp exp1, Exp exp2, Context context, Text &pr
22872287
case ADD(__) then '(<%e1%> + <%e2%>)'
22882288
case SUB(__) then '(<%e1%> - <%e2%>)'
22892289
case MUL(__) then '(<%e1%> * <%e2%>)'
2290-
case DIV(__) then '(<%e1%> / <%e2%>)'
2290+
case DIV(__) then
2291+
let e2str = Util.escapeModelicaStringToCString(ExpressionDumpTpl.dumpExp(exp2,"\""))
2292+
match context
2293+
case ALGLOOP_CONTEXT(genInitialisation = false)
2294+
then
2295+
<<
2296+
division(<%e1%>,<%e2%>,!_system->_initial,"<%e2str%>")
2297+
>>
2298+
else
2299+
<<
2300+
division(<%e1%>,<%e2%>,!_initial,"<%e2str%>")
2301+
>>
2302+
end match
22912303
case POW(__) then 'std::pow(<%e1%>, <%e2%>)'
22922304
case AND(__) then '(<%e1%> && <%e2%>)'
22932305
case OR(__) then '(<%e1%> || <%e2%>)'

0 commit comments

Comments
 (0)