Skip to content

Commit fbd15e9

Browse files
committed
opt: Fix build issue with gcc 16
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.
1 parent cb38b23 commit fbd15e9

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

source/opt/decoration_manager.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,7 @@ 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() && op.words[0] == from) { // add new pair of operands: (to, literal)
547547
inst->AddOperand(
548548
Operand(spv_operand_type_t::SPV_OPERAND_TYPE_ID, {to}));
549549
op = inst->GetOperand(i + 1);

0 commit comments

Comments
 (0)