Skip to content

Commit

Permalink
fix crash when displaying an error message
Browse files Browse the repository at this point in the history
to test:
- git clone https://github.com/OpenModelica/BUAVSystem.git
- build model:
  BUAVSystem.Examples.ValidationCases.IntegratedSystemValidationMar6
- crashes in:
  RemoveSimpleEquations.mo:3156 because "str "is defined only on one branch
  • Loading branch information
adrpo committed Jun 8, 2020
1 parent 44e406f commit 5ae3010
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions OMCompiler/Compiler/BackEnd/RemoveSimpleEquations.mo
Expand Up @@ -3137,12 +3137,12 @@ algorithm
then BackendVariable.setVarStartValueOption(v, start);

case (_, true, (_, values), BackendDAE.SHARED(globalKnownVars=globalKnownVars)) algorithm
v := BackendVariable.setVarFixed(inVar, true);
// get all nonzero values
zerofreevalues := List.fold(values, getZeroFreeValues, {});
if not Flags.isSet(Flags.ALIAS_CONFLICTS) then
Error.addMessage(Error.CONFLICTING_ALIAS_SET, {});
else
v := BackendVariable.setVarFixed(inVar, true);
// get all nonzero values
zerofreevalues := List.fold(values, getZeroFreeValues, {});
str := "Conflicting start values for fixed states:\n";
for value in zerofreevalues loop
(startExp, cr) := value;
Expand All @@ -3152,9 +3152,10 @@ algorithm
end if;
str := str + " * Candidate: " + ComponentReference.printComponentRefStr(cr) + "(start = " + ExpressionDump.printExpStr(startExp) + ", confidence number = " + intString(i) + ")\n";
end for;
Error.addCompilerError(str);
end if;
Error.addCompilerError(str);
then fail(); //selectFreeValue1(zerofreevalues, {}, "Fixed Alias set with conflicting start values\n", "start", BackendVariable.setVarStartValue, v, globalKnownVars);
then
fail(); //selectFreeValue1(zerofreevalues, {}, "Fixed Alias set with conflicting start values\n", "start", BackendVariable.setVarStartValue, v, globalKnownVars);

// fixed false only one start value -> nothing changed
case (_, false, (_, {(start, _)}), _)
Expand Down

0 comments on commit 5ae3010

Please sign in to comment.