Skip to content

Commit c28f593

Browse files
dneto0JoseExposito
andauthored
opt: Fix build issue with gcc 16 (replaeces PR KhronosGroup#6542) (KhronosGroup#6567)
Compiling with gcc 16 throws this error: FAILED: [code=1] source/opt/CMakeFiles/SPIRV-Tools-opt.dir/decoration_manager.cpp.o source/opt/decoration_manager.cpp: In member function ‘spvtools::opt::analysis::DecorationManager::CloneDecorations(unsigned int, unsigned int)’: source/opt/decoration_manager.cpp:546:27: error: ‘MEM[(unsigned int &)&op + 24]’ may be used uninitialized [-Werror=maybe-uninitialized] 546 | if (op.words[0] == from) { // add new pair of operands: (to, literal) source/opt/decoration_manager.cpp:545:19: note: ‘op’ declared here 545 | Operand op = inst->GetOperand(i); | ^~ cc1plus: all warnings being treated as errors Make sure that the vector is not empty before using it. Co-authored-by: José Expósito <[email protected]>
1 parent 6b956f3 commit c28f593

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

source/opt/decoration_manager.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,8 @@ void DecorationManager::CloneDecorations(uint32_t from, uint32_t to) {
543543
const uint32_t num_operands = inst->NumOperands();
544544
for (uint32_t i = 1; i < num_operands; i += 2) {
545545
Operand op = inst->GetOperand(i);
546-
if (op.words[0] == from) { // add new pair of operands: (to, literal)
546+
if (!op.words.empty() &&
547+
op.words[0] == from) { // add new pair of operands: (to, literal)
547548
inst->AddOperand(
548549
Operand(spv_operand_type_t::SPV_OPERAND_TYPE_ID, {to}));
549550
op = inst->GetOperand(i + 1);

0 commit comments

Comments
 (0)