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
Pick-to: 5.15
Change-Id: I552d244076a447ab92d7fffd1617875fdd8dbe62
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
bb10
Thiago Macieira 2020-06-11 08:37:19 -07:00
parent 274e07a339
commit 3caeb0187d
1 changed files with 7 additions and 0 deletions

View File

@ -162,6 +162,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__))