diff --git a/.gitattributes b/.gitattributes index d93a4532a6..b1c811b585 100644 --- a/.gitattributes +++ b/.gitattributes @@ -18471,6 +18471,7 @@ tests/webtbs/tw3768.pp svneol=native#text/plain tests/webtbs/tw3774.pp svneol=native#text/plain tests/webtbs/tw3777.pp svneol=native#text/plain tests/webtbs/tw3778.pp svneol=native#text/plain +tests/webtbs/tw37780.pp svneol=native#text/plain tests/webtbs/tw3780.pp svneol=native#text/plain tests/webtbs/tw3782.pp svneol=native#text/plain tests/webtbs/tw3796.pp svneol=native#text/plain diff --git a/compiler/nadd.pas b/compiler/nadd.pas index 0bac5e4322..5b36920c92 100644 --- a/compiler/nadd.pas +++ b/compiler/nadd.pas @@ -1348,7 +1348,7 @@ implementation (left.nodetype=equaln) and (right.nodetype=equaln) and (not might_have_sideeffects(left)) and - (not might_have_sideeffects(right)) and + (not might_have_sideeffects(right,[mhs_exceptions])) and (is_constintnode(taddnode(left).left) or is_constintnode(taddnode(left).right) or is_constpointernode(taddnode(left).left) or is_constpointernode(taddnode(left).right) or is_constcharnode(taddnode(left).left) or is_constcharnode(taddnode(left).right)) and diff --git a/tests/webtbs/tw37780.pp b/tests/webtbs/tw37780.pp new file mode 100644 index 0000000000..2cdb66496e --- /dev/null +++ b/tests/webtbs/tw37780.pp @@ -0,0 +1,18 @@ +program testbug; + +type + PTestRec = ^TTestRec; + TTestRec = record + Val: Integer; + Next: PTestRec; + end; + +var + TR: TTestRec; + +begin + TR.Val := 6; + TR.Next := nil; + if (TR.Val = 10) or ((TR.Val = 5) and (TR.Next^.Val = 5)) then + Writeln('OK'); +end.