﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc
3765	Bad macro for semiLinear	crupp@…	somebody	"In openmodelica.h the macro for semiLinear is defined as:
#define semiLinear(x,positiveSlope,negativeSlope) (x>=0?positiveSlope*x:negativeSlope*x)

If x is an expression such as x=-1+a/b then the macro evaluates it incorrectly.

It should be:
#define semiLinear(x,positiveSlope,negativeSlope) (x>=0?positiveSlope*(x):negativeSlope*(x))

The added parentheses fix the issue. I've attached a test case that illustrates the issue. In this test the expression is transformed into semiLinear(-1+d/L,k,0).

It turns out that this is a long-standing issue since it was implemented (2010). Maybe it will magically fix some test cases."	defect	closed	blocker	1.11.0	Run-time	v1.10.0-dev-nightly	fixed		Rüdiger Franke Niklas Worschech
