#2368 closed defect (fixed)
Record with 0-length array
Reported by: | Owned by: | Martin Sjölund | |
---|---|---|---|
Priority: | blocker | Milestone: | 1.9.0 |
Component: | Code Generation | Version: | 1.9.0Beta |
Keywords: | Cc: |
Description (last modified by )
model emptyVector4 record R constant Boolean fixedMixingRatio; constant Integer nc_propertyCalculation(min=1); final constant Integer nc=if fixedMixingRatio then 1 else nc_propertyCalculation; constant Real[nc_propertyCalculation] mixingRatio_propertyCalculation; constant Real[nc] defaultMixingRatio = if fixedMixingRatio then {1} else mixingRatio_propertyCalculation; constant Real xi_default[nc-1] = defaultMixingRatio[1:end-1]/sum(defaultMixingRatio); end R; record R2=R(nc_propertyCalculation=1,fixedMixingRatio=false,mixingRatio_propertyCalculation={1}); R2 r2; end emptyVector4;
The type of xi_default cannot be determined. Unusable source code is generated. (r15030)
Change History (7)
comment:1 by , 11 years ago
Description: | modified (diff) |
---|
comment:2 by , 11 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
Summary: | Record, inheritance and real vectors → Record with 0-length array |
comment:3 by , 11 years ago
Component: | Backend → Code Generation |
---|
comment:5 by , 11 years ago
new seems to work, but i cannot access the variables properly
model emptyVector4 record R constant Boolean fixedMixingRatio; constant Integer nc_propertyCalculation(min=1); final constant Integer nc=if fixedMixingRatio then 1 else nc_propertyCalculation; constant Real[nc_propertyCalculation] mixingRatio_propertyCalculation; constant Real[nc] defaultMixingRatio = if fixedMixingRatio then {1} else mixingRatio_propertyCalculation; constant Real xi_default[nc-1] = defaultMixingRatio[1:end-1]/sum(defaultMixingRatio); end R; record R2=R(nc_propertyCalculation=1,fixedMixingRatio=false,mixingRatio_propertyCalculation={1}); R2 r2; Real x[r2.nc-1]=r2.defaultMixingRatio[1:end-1]/sum(r2.defaultMixingRatio); end emptyVector4;
comment:6 by , 11 years ago
What do you mean you cannot access variables properly?
OpenModelica removes zero size arrays from the DAE and
they do not appear in the .mat file.
Note:
See TracTickets
for help on using tickets.
No, type of xi_default is determined. It is just that it has zero-dimensions, which requires special care when generating code (the empty array has unknown/uninteresting type).