From 3fc5d134a3c5387f1b6061fdcab6b7146c579ad5 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 30 Aug 2020 23:51:12 +0200 Subject: [PATCH] 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. --- include/wx/string.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/include/wx/string.h b/include/wx/string.h index ab0a72b737..2dc071290a 100644 --- a/include/wx/string.h +++ b/include/wx/string.h @@ -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; }