Skip to content

Commit 158d675

Browse files
committed
Value-initialize CompiledInstr::opcode
cppcheck (uninitMemberVarNoCtor) flags the scalar `opcode` member as having no initializer while its sibling container members self-init. Every real construction aggregate-initializes all fields, so this was never a live bug, but value-initializing it gives a default-constructed instr a defined opcode and keeps the check clean. Surfaced by the brew cppcheck (2.21) in CI, which enables this check where the older local 2.13 did not. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AXguXGhUbH1pXz3Cdr7xec
1 parent 5760606 commit 158d675

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

c_src/emily/program.hpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,10 @@ inline int64_t index_of(int64_t r) { return r & kIndexMask; }
5353
class Program;
5454

5555
struct CompiledInstr {
56-
Opcode opcode;
56+
// Value-initialized so a default-constructed instr has a defined opcode
57+
// (the other members are containers that self-initialize). Every real
58+
// construction aggregate-initializes all fields, overriding this.
59+
Opcode opcode{};
5760
std::vector<int64_t> operands; // packed refs
5861
std::vector<std::vector<int64_t>> iattrs; // integer attrs (shapes/axes/dtype codes)
5962
// Nested programs an instruction carries (empty for all but control

0 commit comments

Comments
 (0)