QLibrary: Suppress GCC 12 warning about dangling pointer access
Introduced in commit d07742f333
. Reported
by GCC 12:
qlibrary.cpp:672:9: error: dangling pointer to ‘candidates’ may be used [-Werror=dangling-pointer=]
672 | if (isValidSuffix(*it++))
| ^~
qlibrary.cpp:634:29: note: ‘candidates’ declared here
634 | const QLatin1String candidates[] = {
| ^~~~~~~~~~
This is a false positive report because the lambda does not return a
pointer or iterator. But it's a good update anyway to keep the array
outside the lambda, so it won't be recreated every time.
See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104492
Pick-to: 6.3
Change-Id: I74249c52dc02478ba93cfffd16d230abd1bf6166
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
This commit is contained in:
parent
0a41399c2d
commit
81b9ee66b8
@ -629,7 +629,6 @@ bool QLibrary::isLibrary(const QString &fileName)
|
||||
if (completeSuffix.isEmpty())
|
||||
return false;
|
||||
|
||||
auto isValidSuffix = [](QStringView s) {
|
||||
// if this throws an empty-array error, you need to fix the #ifdef's:
|
||||
const QLatin1String candidates[] = {
|
||||
# if defined(Q_OS_HPUX)
|
||||
@ -652,6 +651,8 @@ bool QLibrary::isLibrary(const QString &fileName)
|
||||
QLatin1String("so"),
|
||||
# endif
|
||||
}; // candidates
|
||||
|
||||
auto isValidSuffix = [&candidates](QStringView s) {
|
||||
return std::find(std::begin(candidates), std::end(candidates), s) != std::end(candidates);
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user