Opened 9 years ago
Last modified 9 years ago
#3411 new defect
Compiler does not detect unassigned variable in some cases with if equations — at Initial Version
Reported by: | Adrian Pop | Owned by: | Martin Sjölund |
---|---|---|---|
Priority: | high | Milestone: | Future |
Component: | MetaModelica | Version: | trunk |
Keywords: | Cc: | Willi Braun |
Description
The compiler does not detect that b3 is not assigned and because of that the behavior is undefined and random. See also:
See also 92eaf4/OMCompiler
protected function inlineWhenEq "inlines function calls in when equations" input BackendDAE.WhenEquation inWhenEquation; input Inline.Functiontuple fns; input DAE.ElementSource inSource; output BackendDAE.WhenEquation outWhenEquation; output DAE.ElementSource outSource; output Boolean inlined; algorithm (outWhenEquation,outSource,inlined) := matchcontinue(inWhenEquation) local DAE.ComponentRef cref; DAE.Exp e,e_1,cond; BackendDAE.WhenEquation weq,weq_1; DAE.ElementSource source; Boolean b1,b2,b3; list<DAE.Statement> assrtLst; BackendDAE.WhenEquation we, elsewe; Option<BackendDAE.WhenEquation> oelsewe; list<BackendDAE.WhenOperator> whenStmtLst; case BackendDAE.WHEN_STMTS(condition=cond, whenStmtLst=whenStmtLst, elsewhenPart = oelsewe) equation (cond, source, b1,_) = Inline.inlineExp(cond, fns, inSource); (whenStmtLst, b2) = inlineWhenOps(whenStmtLst, fns); if isSome(oelsewe) then SOME(elsewe) = oelsewe; (elsewe, source, b3) = inlineWhenEq(elsewe, fns, source); oelsewe = SOME(elsewe); else oelsewe = NONE(); // the compiler does not detect that b3 is not assigned // b3 = false; end if; then (BackendDAE.WHEN_STMTS(cond, whenStmtLst, oelsewe), source, b1 or b2 or b3); end matchcontinue; end inlineWhenEq;
Note:
See TracTickets
for help on using tickets.