From 604142da3ad903b4a67e88167211715dacdda1e8 Mon Sep 17 00:00:00 2001 From: Dennis Felsing Date: Wed, 25 May 2022 17:55:21 +0200 Subject: [PATCH] Try other fix for tautological --- CMakeLists.txt | 1 - src/game/client/components/maplayers.cpp | 5 ++++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 09c966514..5f9d42ae9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -335,7 +335,6 @@ if(NOT MSVC AND NOT HAIKU AND NOT TARGET_OS STREQUAL "mac") add_cxx_compiler_flag_if_supported(OUR_FLAGS_OWN -Wformat=2) # Warn about format strings. add_c_compiler_flag_if_supported(OUR_FLAGS_DEP -Wno-implicit-function-declaration) add_cxx_compiler_flag_if_supported(OUR_FLAGS_OWN -Wno-nullability-completeness) # Mac OS build on github - add_cxx_compiler_flag_if_supported(OUR_FLAGS_OWN -Wno-tautological-constant-out-of-range-compare) # Check needed for x86, but warns on x86-64 add_cxx_compiler_flag_if_supported(OUR_FLAGS_OWN -Wduplicated-cond) add_cxx_compiler_flag_if_supported(OUR_FLAGS_OWN -Wduplicated-branches) add_cxx_compiler_flag_if_supported(OUR_FLAGS_OWN -Wlogical-op) diff --git a/src/game/client/components/maplayers.cpp b/src/game/client/components/maplayers.cpp index b4ccee3df..400550c86 100644 --- a/src/game/client/components/maplayers.cpp +++ b/src/game/client/components/maplayers.cpp @@ -298,8 +298,11 @@ bool CMapLayers::STileLayerVisuals::Init(unsigned int Width, unsigned int Height { m_Width = Width; m_Height = Height; - if(Width == 0 || Height == 0 || Width >= std::numeric_limits::max() || Height >= std::numeric_limits::max()) + if(Width == 0 || Height == 0) return false; + if constexpr(sizeof(unsigned int) >= sizeof(ptrdiff_t)) + if(Width >= std::numeric_limits::max() || Height >= std::numeric_limits::max()) + return false; m_pTilesOfLayer = new CMapLayers::STileLayerVisuals::STileVisual[Height * Width];