From c02709f697fdf09c8b62e7cd9b85a7ccdd2c36e4 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 11 Jun 2020 08:37:19 -0700 Subject: qustrlen: Add #warnings to explain how to deal with GCC 7.x's ASan The build breaks by disabling ASan in this function because it also removes its ability to emit SSE2 code. That's clearly broken because all x86_64 can use SSE2. So this adds #warnings so people are told how to choose their solution. Clang doesn't currently define __SANITIZE_ADDRESS__ but I added a conditional just in case some future version does. Fixes: QTBUG-84856 Change-Id: I552d244076a447ab92d7fffd1617875fdd8dbe62 Reviewed-by: Mitch Curtis (cherry picked from commit 3caeb0187dec592c78a3bde8d0284475e00e30d4) Reviewed-by: Qt Cherry-pick Bot --- src/corelib/text/qstring.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/corelib/text') diff --git a/src/corelib/text/qstring.cpp b/src/corelib/text/qstring.cpp index a008aaf41e..d9dd8ab30b 100644 --- a/src/corelib/text/qstring.cpp +++ b/src/corelib/text/qstring.cpp @@ -160,6 +160,13 @@ static inline bool qt_ends_with(QStringView haystack, QLatin1String needle, Qt:: static inline bool qt_ends_with(QStringView haystack, QChar needle, Qt::CaseSensitivity cs); #if defined(__SSE2__) && defined(Q_CC_GNU) && !defined(Q_CC_INTEL) +# if defined(__SANITIZE_ADDRESS__) && Q_CC_GNU < 800 && !defined(Q_CC_CLANG) +# warning "The __attribute__ on below will likely cause a build failure with your GCC version. Your choices are:" +# warning "1) disable ASan;" +# warning "2) disable the optimized code in qustrlen (change __SSE2__ to anything else);" +# warning "3) upgrade your compiler (preferred)." +# endif + // We may overrun the buffer, but that's a false positive: // this won't crash nor produce incorrect results __attribute__((__no_sanitize_address__)) -- cgit v1.2.3