diff options
author | jeremyg-lunarg <jeremyg@lunarg.com> | 2022-08-04 10:44:15 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-04 16:44:15 +0000 |
commit | b362d2b7d45abb2ddba16c45638366fe508a831a (patch) | |
tree | 85c8ed42ee1e411ff23dcfce24da7dd8ec814a3f | |
parent | 08c542d344c697142b1bbea469b2b4152fa1c074 (diff) | |
download | SPIRV-Tools-b362d2b7d45abb2ddba16c45638366fe508a831a.tar.gz |
spirv-diff: Fix asserts in ComparePreambleInstructions() (#4872)
These asserts are not valid for string literals, which may
contain several words:
assert(a_operand.words.size() == 1);
assert(b_operand.words.size() == 1);
It looks like they only make sense for the default case, which
assumes that both operands contain a single word.
Running a debug version of spirv-diff on any shader containing
a string literal will hit the original asserts.
-rw-r--r-- | source/diff/diff.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/source/diff/diff.cpp b/source/diff/diff.cpp index bca31b06..17750ff2 100644 --- a/source/diff/diff.cpp +++ b/source/diff/diff.cpp @@ -758,9 +758,6 @@ int Differ::ComparePreambleInstructions(const opt::Instruction* a, return 1; } - assert(a_operand.words.size() == 1); - assert(b_operand.words.size() == 1); - switch (a_operand.type) { case SPV_OPERAND_TYPE_ID: // Don't compare ids, there can't be multiple instances of the @@ -781,6 +778,9 @@ int Differ::ComparePreambleInstructions(const opt::Instruction* a, } default: // Expect literal values to match. + assert(a_operand.words.size() == 1); + assert(b_operand.words.size() == 1); + if (a_operand.words[0] < b_operand.words[0]) { return -1; } |