qlibrary_unix: work around compile bug in gcc5.4
GCC5.4 generates incorrect code. The QString object which is passed by value to f-lambda, has been corrupted by the time this lambda returns. Accessing this object causes memory corruption. The same can be reproduced with std::list and std::string Task-number: QTBUG-69394 Change-Id: I22522d2ddd1d5226de0aff378133d18391e370de Reviewed-by: Gatis Paeglis <gatis.paeglis@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
cc5d816800
commit
0826aeddd2
@ -182,21 +182,23 @@ bool QLibraryPrivate::load_sys()
|
||||
|
||||
#if defined(Q_PROCESSOR_X86) && !defined(Q_OS_DARWIN)
|
||||
if (qCpuHasFeature(ArchHaswell)) {
|
||||
auto transform = [](QStringList &list, QString (*f)(QString)) {
|
||||
auto transform = [](QStringList &list, void (*f)(QString *)) {
|
||||
QStringList tmp;
|
||||
qSwap(tmp, list);
|
||||
list.reserve(tmp.size() * 2);
|
||||
for (const QString &s : qAsConst(tmp)) {
|
||||
list.append(f(s));
|
||||
QString modifiedPath = s;
|
||||
f(&modifiedPath);
|
||||
list.append(modifiedPath);
|
||||
list.append(s);
|
||||
}
|
||||
};
|
||||
if (pluginState == IsAPlugin) {
|
||||
// add ".avx2" to each suffix in the list
|
||||
transform(suffixes, [](QString s) { return s.append(QLatin1String(".avx2")); });
|
||||
transform(suffixes, [](QString *s) { s->append(QLatin1String(".avx2")); });
|
||||
} else {
|
||||
// prepend "haswell/" to each prefix in the list
|
||||
transform(prefixes, [](QString s) { return s.prepend(QLatin1String("haswell/")); });
|
||||
transform(prefixes, [](QString *s) { s->prepend(QLatin1String("haswell/")); });
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user