Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#5112 closed defect (fixed)

Template optInitValFMU in CodegenFMU.tpl generates wrong code for integers

Reported by: tknodt@… Owned by: Adrian Pop
Priority: high Milestone: Future
Component: FMI Version: v1.13.0-dev-nightly
Keywords: Cc:

Description

I was wondering that I get constant overflow warnings when compiling a FMU for win32.
Warning when compiling (this should IMHO be an error):

XXX_init_fmu.c:7757:55: warning: overflow in implicit constant conversion [-Woverflow]

modelData->integerParameterData[17].attribute.min = -DBL_MAX;

The bug is in CodegenFMU.tpl, where the template optInitValFMU uses -DBL_MAX and DBL_MAX for min and max for the data type integer.
This has to be replaced by LONG_MIN and LONG_MAX.

Change History (5)

comment:1 by Adrian Pop, 6 years ago

Owner: changed from Lennart Ochel to Adrian Pop
Status: newaccepted

I thought I fixed that but it seems not :)
https://github.com/OpenModelica/OMCompiler/pull/2640

comment:2 by Adrian Pop, 6 years ago

Resolution: fixed
Status: acceptedclosed

comment:3 by tknodt@…, 6 years ago

Thanks for the quick fix.
IMHO it would be better to use LONG_MIN instead of -LONG_MAX.

comment:4 by Adrian Pop, 6 years ago

Yeah, I thought so too, but I wanted to use the same pattern as for DBL_MAX.

LONG_MIN	Minimum value for an object of type long int	-2147483647 (-231+1) or less*
LONG_MAX	Maximum value for an object of type long int	2147483647 (231-1) or greater*

The result is thou' the same, I'll think about changing it.

comment:5 by Adrian Pop, 6 years ago

Version: v1.12.0v1.13.0-dev-nightly
Note: See TracTickets for help on using tickets.