[Mesa-dev] [PATCH 02/11] intel/compiler: silence -Wclass-memaccess warnings
Caio Marcelo de Oliveira Filho
caio.oliveira at intel.com
Mon Jul 16 22:36:34 UTC 2018
G++ 8.1.1 suggests we shouldn't be setting and copying value from
instances of classes directly, so make clear this is what we want to
do.
---
I had mixed feelings about this fix. An alternative would be to
improve how fs_inst, fs_reg and other values are created and copied,
but it didn't seem worth doing that just for the sake of getting rid
of the warning. So, postponing such refactoring to a moment we need to
touch those classes for other reasons.
src/intel/compiler/brw_fs.cpp | 6 +++---
src/intel/compiler/brw_vec4.cpp | 4 ++--
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/src/intel/compiler/brw_fs.cpp b/src/intel/compiler/brw_fs.cpp
index 2b8363ca362..8c8dfb706de 100644
--- a/src/intel/compiler/brw_fs.cpp
+++ b/src/intel/compiler/brw_fs.cpp
@@ -49,7 +49,7 @@ void
fs_inst::init(enum opcode opcode, uint8_t exec_size, const fs_reg &dst,
const fs_reg *src, unsigned sources)
{
- memset(this, 0, sizeof(*this));
+ memset((void*)this, 0, sizeof(*this));
this->src = new fs_reg[MAX2(sources, 3)];
for (unsigned i = 0; i < sources; i++)
@@ -131,7 +131,7 @@ fs_inst::fs_inst(enum opcode opcode, uint8_t exec_width, const fs_reg &dst,
fs_inst::fs_inst(const fs_inst &that)
{
- memcpy(this, &that, sizeof(that));
+ memcpy((void*)this, &that, sizeof(that));
this->src = new fs_reg[MAX2(that.sources, 3)];
@@ -408,7 +408,7 @@ fs_inst::can_change_types() const
void
fs_reg::init()
{
- memset(this, 0, sizeof(*this));
+ memset((void*)this, 0, sizeof(*this));
type = BRW_REGISTER_TYPE_UD;
stride = 1;
}
diff --git a/src/intel/compiler/brw_vec4.cpp b/src/intel/compiler/brw_vec4.cpp
index e0d6476dea6..4e242e03032 100644
--- a/src/intel/compiler/brw_vec4.cpp
+++ b/src/intel/compiler/brw_vec4.cpp
@@ -41,7 +41,7 @@ namespace brw {
void
src_reg::init()
{
- memset(this, 0, sizeof(*this));
+ memset((void*)this, 0, sizeof(*this));
this->file = BAD_FILE;
this->type = BRW_REGISTER_TYPE_UD;
}
@@ -83,7 +83,7 @@ src_reg::src_reg(const dst_reg ®) :
void
dst_reg::init()
{
- memset(this, 0, sizeof(*this));
+ memset((void*)this, 0, sizeof(*this));
this->file = BAD_FILE;
this->type = BRW_REGISTER_TYPE_UD;
this->writemask = WRITEMASK_XYZW;
--
2.18.0
More information about the mesa-dev
mailing list