Suppress strange -Wunsafe-loop-optimizations in wxString code

The error message

wx/string.h:558:47: error: missed loop optimization, the loop counter may overflow
                    [-Werror=unsafe-loop-optimizations]
       for ( Cache::Element *c = cacheBegin; c != cacheEnd; c++ )
                                             ~~^~~~~~~~~~~

doesn't seem to really make much sense, as it shouldn't overflow here.
This commit is contained in:
Vadim Zeitlin
2020-08-30 23:51:12 +02:00
parent a535d2c64d
commit 3fc5d134a3

View File

@@ -554,6 +554,12 @@ private:
if ( cacheBegin == NULL )
return NULL;
#endif
// gcc 7 warns about not being able to optimize this loop because of
// possible loop variable overflow, really not sure what to do about
// this, so just disable this warnings for now
wxGCC_ONLY_WARNING_SUPPRESS(unsafe-loop-optimizations)
Cache::Element * const cacheEnd = GetCacheEnd();
for ( Cache::Element *c = cacheBegin; c != cacheEnd; c++ )
{
@@ -561,6 +567,8 @@ private:
return c;
}
wxGCC_ONLY_WARNING_RESTORE(unsafe-loop-optimizations)
return NULL;
}