This is a workaround that was suggested previously.
For me it hugely improves the situation with wxWidgets 3.1.
--- a/include/wx/window.h
+++ b/include/wx/window.h
@@ -1695,7 +1695,9 @@ protected:
wxDEPRECATED_MSG("use SetInitialSize() instead.")
void SetBestSize(const wxSize& size);
+#if !wxCHECK_GCC_VERSION(5, 0)
wxDEPRECATED_MSG("use SetInitialSize() instead.")
+#endif
virtual void SetInitialBestSize(const wxSize& size);