Opened 7 years ago

Closed 7 years ago

#4571 closed defect (fixed)

MetaModelica function pointer with underscore generates invalid code

Reported by: Per Östlund Owned by: Martin Sjölund
Priority: normal Milestone: 1.13.0
Component: MetaModelica Version: v1.13.0-dev-nightly
Keywords: Cc:

Description

A MetaModelica function pointer that has an underscore in its name causes the code generation to expand the underscore to __ when using the function, but not when declaring it. For example:

  partial function pf
  end pf;
    
  pf fu_nc = f;
algorithm
  fu_nc();

generates the following C-code (note _fu_nc on first lines and _fu__nc on last):

  modelica_fnptr _fu_nc;
  MMC_SO();
  _tailrecursive: OMC_LABEL_UNUSED
  _fu_nc = boxvar_f;
  (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_fu__nc), 2))) ? ((void(*)(threadData_t*, modelica_metatype)) (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_fu__nc), 1)))) (threadData, (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_fu__nc), 2)))) : ((void(*)(threadData_t*)) (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_fu__nc), 1)))) (threadData);

Attachments (1)

test.mos (259 bytes ) - added by Per Östlund 7 years ago.

Download all attachments as: .zip

Change History (3)

by Per Östlund, 7 years ago

Attachment: test.mos added

comment:1 by Martin Sjölund, 7 years ago

Milestone: Future1.13.0
Status: newaccepted

comment:2 by Martin Sjölund, 7 years ago

Resolution: fixed
Status: acceptedclosed
Note: See TracTickets for help on using tickets.