From ef528e1801a1e116d2995860546a62fd04fa9ee7 Mon Sep 17 00:00:00 2001 From: Orgad Shaneh Date: Tue, 8 May 2018 19:36:12 +0300 Subject: [PATCH] QmlProfiler: Avoid memcpy for non-POD object Replace with assignments/memcpy for members. Detected by GCC8. Change-Id: I9866ea0215cf5d43b55ed10d21e4efa371315365 Reviewed-by: Ulf Hermann --- src/plugins/qmlprofiler/qmlevent.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/plugins/qmlprofiler/qmlevent.h b/src/plugins/qmlprofiler/qmlevent.h index dd8515e0bcd..23a62cb643f 100644 --- a/src/plugins/qmlprofiler/qmlevent.h +++ b/src/plugins/qmlprofiler/qmlevent.h @@ -68,8 +68,9 @@ struct QmlEvent : public Timeline::TraceEvent { } QmlEvent(QmlEvent &&other) + : TraceEvent(other), m_dataType(other.m_dataType), m_dataLength(other.m_dataLength) { - memcpy(this, &other, sizeof(QmlEvent)); + memcpy(&m_data, &other.m_data, sizeof(m_data)); other.m_dataType = Inline8Bit; // prevent dtor from deleting the pointer } @@ -88,7 +89,10 @@ struct QmlEvent : public Timeline::TraceEvent { QmlEvent &operator=(QmlEvent &&other) { if (this != &other) { - memcpy(this, &other, sizeof(QmlEvent)); + TraceEvent::operator=(other); + m_dataType = other.m_dataType; + m_dataLength = other.m_dataLength; + memcpy(&m_data, &other.m_data, sizeof(m_data)); other.m_dataType = Inline8Bit; } return *this;