Opened 12 years ago
Closed 12 years ago
#2675 closed defect (fixed)
Issues when returning funref from function with multiple outputs
| Reported by: | Per Östlund | Owned by: | Martin Sjölund |
|---|---|---|---|
| Priority: | high | Milestone: | Bootstrapping |
| Component: | MetaModelica | Version: | trunk |
| Keywords: | Cc: |
Description
Returning function references from a function which has multiple outputs causes some issues in the bootstrapped compiler:
encapsulated package P partial function PF input Real x; output Real y; end PF; function f input Real x; output Real y; algorithm y := x; end f; function f2 input String s; output Real r; output PF pf; algorithm (r, pf) := match(s) case _ then (1.0, f); end match; end f2; function f3 input String s; output Real r; output PF pf; algorithm (r, pf) := match(s) local PF lpf; // Avoid template error by returning the function indirectly. case _ equation lpf = f; then (1.0, lpf); end match; end f3; end P;
Running this package through OpenModelica.Scripting.generateSeparateCode gives an error for f2:
[CodegenC.tpl:10056:14-10056:14:writable] Error: Template error: expTypeShort:#FUNCTION_REFERENCE_FUNC#.P.f<function>(Real x) => Real
Commenting out f2 makes generateSeparateCode succeed, but generated invalid code for f3. The issue is the second last line in the generated omc_P_f3 function:
if (outomc_pf) { *outomc_pf = (modelica_fnptr)omc_pf; }
The issue with this is simply that outomc_pf is not declared anywhere.
Change History (2)
comment:1 by , 12 years ago
| Status: | new → accepted |
|---|
comment:2 by , 12 years ago
| Resolution: | → fixed |
|---|---|
| Status: | accepted → closed |
Note:
See TracTickets
for help on using tickets.

Fixed in r20254.