fixed incorrect ZAM optimization of expressions seen in single-statement inlined functions

This commit is contained in:
Vern Paxson 2025-04-29 14:29:07 -07:00
parent 8054547712
commit d2762fb247
3 changed files with 43 additions and 4 deletions

View file

@ -0,0 +1,2 @@
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
T, [field1=3], 3

View file

@ -0,0 +1,30 @@
# @TEST-DOC: Regression test for incorrect reuse of temporaries when inlining
# @TEST-REQUIRES: test "${ZEEK_USE_CPP}" != "1"
# @TEST-EXEC: zeek -b -O ZAM %INPUT >output
# @TEST-EXEC: btest-diff output
type R: record {
field1: count;
};
global yes = T;
function pred(my_R: R): bool
{
# In the following, my_R$field1 will never be evaluated ...
if ( yes || my_R$field1 == 4 )
return T;
else
return F;
}
event zeek_init()
{
local my_R = R($field1=3);
# ... prior to the regression, the third argument in this print
# was taken from the temporary in pred() that *would* have held
# my_R$field1 had that ever been evaluated, but instead it holds
# the default ZVal value of 0.
print pred(my_R), my_R, my_R$field1;
}