From de5cb565252b921048617a6d3d61921f27e73d3b Mon Sep 17 00:00:00 2001 From: Mathew Sutcliffe Date: Fri, 23 Jun 2017 18:17:55 +0100 Subject: [PATCH] Fixed strict aliasing warning Summary: Use `noquote` method instead of relying on undefined behaviour. This fixes a warning in GCC 6.3. `noquote` method was added in Qt 5.4. Reviewers: #swift_pilot_client, kbasan Reviewed By: kbasan Subscribers: jenkins Tags: #swift_pilot_client Differential Revision: https://dev.swift-project.org/D26 --- src/blackmisc/logmessage.cpp | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/blackmisc/logmessage.cpp b/src/blackmisc/logmessage.cpp index 5eed72bd0..e289528a8 100644 --- a/src/blackmisc/logmessage.cpp +++ b/src/blackmisc/logmessage.cpp @@ -30,14 +30,7 @@ namespace BlackMisc CLogMessage::~CLogMessage() { - // ostream(encodedCategory()) << message(); // QDebug::operator<<(QString) puts quote characters around the message - - // hack to avoid putting quote characters around the message - // should be safe, we could directly call qt_message_output instead, but it's undocumented - QByteArray category = qtCategory(); - QDebug debug = ostream(category); - auto &stream = **reinterpret_cast(&debug); // should be safe because it is relying on Qt's guarantee of ABI compatibility - stream << message(); + ostream(qtCategory()).noquote() << message(); } QByteArray CLogMessage::qtCategory() const