﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc
4713	literal double value output by omc exceeds DBL_MAX	john.pye@…	Lennart Ochel	"Hi there

While using omc from the Nightly builds, OpenModelica 1.13.0~dev-536-g587d18b, as well as with previous version 1.12, we receive compiler warnings as follows:

SimpleSystem.c:1160:90: warning: magnitude of floating-point constant too large
      for type 'double'; maximum is 1.7976931348623157E+308 [-Wliteral-range]
  .../* pri.nextTimeEventScaled DISCRETE */,1.797693134862316e+308);
                                            ^
SimpleSystem.c:1161:152: warning: magnitude of floating-point constant too large
      for type 'double'; maximum is 1.7976931348623157E+308 [-Wliteral-range]
  .../* pri.nextTimeEventScaled DISCRETE */:1.797693134862316e+308);
                                            ^
The function that is causing this problem in the OMC C-code output is:

/*
 equation index: 150
 type: WHEN
 
 when {$whenCondition1} then
   pri._nextTimeEvent = if pri.nextTimeEventScaled < 1.797693134862316e+308 then pri.nextTimeEventScaled else 1.797693134862316e+308;
 end when;
 */
void SimpleSystem_eqFunction_150(DATA *data, threadData_t *threadData)
{
  TRACE_PUSH
  const int equationIndexes[2] = {1,150};
  modelica_boolean tmp29;
  if((data->localData[0]->booleanVars[0] /* $whenCondition1 DISCRETE */ && !data->simulationInfo->booleanVarsPre[0] /* $whenCondition1 DISCRETE */ /* edge */))
  {
    tmp29 = Less(data->localData[0]->realVars[70] /* pri.nextTimeEventScaled DISCRETE */,1.797693134862316e+308);
    data->localData[0]->realVars[69] /* pri.nextTimeEvent DISCRETE */ = (tmp29?data->localData[0]->realVars[70] /* pri.nextTimeEventScaled DISCRETE */:1.797693134862316e+308);
  }
  TRACE_POP
}

On close inspection, you can see that the literal double value in the code is slightly rounded up from DBL_MAX.

I think the best solution here would be for the C code from Modelica to output either the macro 'DBL_MAX' or else a value that is safely less than DBL_MAX eg half its value.

Cheers
JP

PS if more details are needed, you can reproduce this bug directly following the instructions at https://github.com/SolarTherm/SolarTherm/wiki/Building-SolarTherm.
"	defect	closed	normal		Third-Party Libraries	v1.13.0-dev-nightly	invalid	compiler, omc	ali.shirazi@…
