[PATCH] D87755: Silence GCC's `-Wclass-memaccess` warnings

Chandler Carruth via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 16 03:53:02 PDT 2020


chandlerc added inline comments.


================
Comment at: llvm/lib/Target/X86/Disassembler/X86Disassembler.cpp:1719-1720
 
   InternalInstruction Insn;
-  memset(&Insn, 0, sizeof(InternalInstruction));
+  memset((void *)&Insn, 0, sizeof(InternalInstruction));
   Insn.bytes = Bytes;
----------------
jhenderson wrote:
> This should work, right?
Not necessarily?

They have at least potentially different semantics (for example, if the default constructor would leave some members uninitialized for some reason). I'm not super familiar with this code and didn't really want to actually change its meaning, just make the compiler warning stop. ;]

If you or another are confident that the code doesn't need the memset, I can switch. Stylistically, I'd suggest:
```
InternalInstruction Isns = {};
```

But that's a minor point.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D87755/new/

https://reviews.llvm.org/D87755



More information about the llvm-commits mailing list