Opened 6 years ago

Closed 6 years ago

#4856 closed defect (fixed)

Expression.isConst failed

Reported by: vitalij Owned by: sjoelund.se
Priority: critical Milestone: 1.13.0
Component: MetaModelica Version:
Keywords: Cc:

Description

In the example
OpenModelica/testsuite/simulation/modelica/others/Bug3885.mos we can find wrong check for expr

expr := min(-(if false then 0.0 else -1.0), min(100000.0, min(if Modelica.Fluid.Types.PortFlowDirection.Bidirectional == Modelica.Fluid.Types.PortFlowDirection.Leaving then 0.0 else 9.999999999999999e+59, min(100000.0, min(100000.0, min(100000.0, 100000.0)))))); 
 Expression.isConst(expr);// false
 ExpressionSimplify.simplify(expr); // 1

(I will mark this issue as critical because it's a base function)

Change History (5)

comment:2 Changed 6 years ago by sjoelund.se

It seems any expression containing builtin calls is considered not constant.

comment:3 Changed 6 years ago by sjoelund.se

I think it's possibly correct to always simplify the expression in this case; simplify catches more things such as an if-condition that can select a constant-expression branch.

I will update isConst though: https://github.com/OpenModelica/OMCompiler/pull/2340

comment:4 Changed 6 years ago by sjoelund.se

It seems this fails due to the ExpressionSolve+CSE doing something bad: it moves the sinh calculation to a separate (initial) equation, but this call should never be executed...

comment:5 Changed 6 years ago by sjoelund.se

  • Milestone changed from Future to 1.13.0
  • Resolution set to fixed
  • Status changed from new to closed

Closing this. But we still have a problem with the CSE modules, etc executing code that never should be executed...

Note: See TracTickets for help on using tickets.