Skip to content

Commit da3dc98

Browse files
jkwak-workcsyonghe
andauthored
Fix an incorrect iteration with a workList (shader-slang#6177)
* Fix an incorrect iteration with a workList We cannot modify workList while iterating it, because its type `List` is actually an array container. * Change based on the feedback * Use `Index` instead of `int` for for-loop index --------- Co-authored-by: Yong He <yonghe@outlook.com>
1 parent 1f1892d commit da3dc98

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

source/slang/slang-ir-variable-scope-correction.cpp

+4-3
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,12 @@ void VariableScopeCorrectionContext::_processFunction(IRFunc* funcInst)
121121

122122
auto instAfterParam = funcInst->getFirstBlock()->getFirstOrdinaryInst();
123123

124-
for (auto inst = workList.begin(); inst != workList.end(); inst++)
124+
for (Index i = 0; i < workList.getCount(); i++)
125125
{
126-
if (auto loopHeaderList = loopHeaderMap.tryGetValue(getBlock(*inst)))
126+
auto inst = workList[i];
127+
if (auto loopHeaderList = loopHeaderMap.tryGetValue(getBlock(inst)))
127128
{
128-
_processInstruction(dominatorTree, instAfterParam, *inst, *loopHeaderList, workList);
129+
_processInstruction(dominatorTree, instAfterParam, inst, *loopHeaderList, workList);
129130
}
130131
}
131132
}

0 commit comments

Comments
 (0)