Fix unintended side-effect insertion on associative array read (#8077)

This commit is contained in:
Adam Kostrzewski
2026-08-14 15:23:44 +02:00
committed by GitHub
parent 0a3657517d
commit 649598c74c
11 changed files with 153 additions and 15 deletions
+2 -2
View File
@@ -485,7 +485,7 @@ void EmitCFunc::emitVarReset(const string& prefix, AstVar* varp, bool constructi
const auto& mapr = initarp->map();
for (const auto& itr : mapr) {
AstNode* const valuep = itr.second->valuep();
emitSetVarConstant(newPrefix + ".at(" + cvtToStr(itr.first) + ")",
emitSetVarConstant(newPrefix + ".atWrite(" + cvtToStr(itr.first) + ")",
VN_AS(valuep, Const));
}
} else if (VN_IS(dtypep, WildcardArrayDType)) {
@@ -496,7 +496,7 @@ void EmitCFunc::emitVarReset(const string& prefix, AstVar* varp, bool constructi
const auto& mapr = initarp->map();
for (const auto& itr : mapr) {
AstNode* const valuep = itr.second->valuep();
emitSetVarConstant(newPrefix + ".at(" + cvtToStr(itr.first) + ")",
emitSetVarConstant(newPrefix + ".atWrite(" + cvtToStr(itr.first) + ")",
VN_AS(valuep, Const));
}
} else if (AstUnpackArrayDType* const adtypep = VN_CAST(dtypep, UnpackArrayDType)) {