Repository navigation
OCT generates non-compiling C code for Complex if-expressions in ComplexOutput equations (ComplexBlocks) - #2
Open
hubertus65 wants to merge 1 commit into
Conversation
OCT generates non-compiling C code for Complex if-expressions in ComplexOutput equations (ComplexBlocks) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UmNZkRw6HV9CeBvNk36AzT
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
ImpactFailures.ComplexIfExpressionInConnectorEquation, a minimal model with MSL 4.1.0 that fails in Modelon Impact (impact.modelon.cloud, checked 2026-10-31).Failure: the generated C code does not compile. The record constructor of the connector
type leaks into the C source:
Trigger: a Complex if-expression written inline in the equation of a
ComplexOutputconnector:y = k*(if useConjugateInput then Modelica.ComplexMath.conj(u) else u)in ComplexMath.Gain, and likewise in Feedback, Division and Add3y = offset + (if time < startTime then Complex(0) else height)in Sources.ComplexStepEach block alone reproduces it, and so do local copies of the blocks. Assigning the if-expression to a
protected
Complexvariable first compiles and simulates. ComplexMath.Add and Product alreadydo this through
u1Internal/u2Internalof Interfaces.ComplexSI2SO.Workaround in the MSL: modelica#4847 uses intermediate variables in
the five blocks. OpenModelica results are bit-identical.
Upstream MSL pull request: modelica#4847
🤖 Generated with Claude Code
https://claude.ai/code/session_01UmNZkRw6HV9CeBvNk36AzT