Opened 7 years ago

Closed 7 years ago

#4856 closed defect (fixed)

Expression.isConst failed

Reported by: Vitalij Ruge Owned by: Martin Sjölund
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 by Martin Sjölund, 7 years ago

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

comment:3 by Martin Sjölund, 7 years ago

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 by Martin Sjölund, 7 years ago

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 by Martin Sjölund, 7 years ago

Milestone: Future1.13.0
Resolution: fixed
Status: newclosed

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.