#5112 closed defect (fixed)
Template optInitValFMU in CodegenFMU.tpl generates wrong code for integers
| Reported by: | 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 , 7 years ago
| Owner: | changed from to | 
|---|---|
| Status: | new → accepted | 
comment:2 by , 7 years ago
| Resolution: | → fixed | 
|---|---|
| Status: | accepted → closed | 
Fixed in 50de54b3/OMCompiler.
comment:3 by , 7 years ago
Thanks for the quick fix.
IMHO it would be better to use LONG_MIN instead of -LONG_MAX.
comment:4 by , 7 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 , 7 years ago
| Version: | v1.12.0 → v1.13.0-dev-nightly | 
|---|


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