<div dir="ltr">In the test suite, MultiSource/Applications/aha/aha.c makes an invalid memory reference. A loop inside <span style="font-family:arial,sans-serif;font-size:13px">main() sets global numi=1 and calls fix_operands(i=0), which executes:</span><div style="font-family:arial,sans-serif;font-size:13px">
<br></div><div style="font-family:arial,sans-serif;font-size:13px"><font face="courier new, monospace">...</font></div><div><div style="font-family:arial,sans-serif;font-size:13px"><font face="courier new, monospace"> if (i == numi - 1) { // If this is the last insn:</font></div>
<div><font face="courier new, monospace"> rs = numi + RI0 - 2; // Second from last reg.<br></font></div><div style="font-family:arial,sans-serif;font-size:13px"><font face="courier new, monospace">...</font></div>
<div><font face="courier new, monospace"> rt = rs - 1; // Third from last reg.<br></font></div><div style="font-family:arial,sans-serif;font-size:13px"><font face="courier new, monospace"> if (pgm[i-1].opnd[0] != rt && ...</font></div>
<div style="font-family:arial,sans-serif;font-size:13px"><font face="courier new, monospace"> ... && rt >= RI0) {<br></font></div><div style="font-family:arial,sans-serif;font-size:13px"><font face="courier new, monospace">...</font></div>
<div style="font-family:arial,sans-serif;font-size:13px"><font face="courier new, monospace"> }</font></div><div style="font-family:arial,sans-serif;font-size:13px"><font face="courier new, monospace"> }</font></div>
<div style="font-family:arial,sans-serif;font-size:13px"><br></div><div style="font-family:arial,sans-serif;font-size:13px">pgm is a global array of structs.</div><div style="font-family:arial,sans-serif;font-size:13px">
<br>
</div><div style="font-family:arial,sans-serif;font-size:13px">One can see that pgm[] is being illegally dereferenced with index -1.</div><div style="font-family:arial,sans-serif;font-size:13px"><br></div><div style="font-family:arial,sans-serif;font-size:13px">
One can also see that the last condition clause, "rt>=RI0", is equivalent to "numi >= 3". The attached patch moves this clause to the beginning of the condition, giving the same result without the illegal reference.</div>
</div><div style="font-family:arial,sans-serif;font-size:13px"><br></div><div style="font-family:arial,sans-serif;font-size:13px">Jim</div></div>