Try other fix for tautological

This commit is contained in:
Dennis Felsing 2022-05-25 17:55:21 +02:00
parent 3a231b07e1
commit 604142da3a
2 changed files with 4 additions and 2 deletions

View file

@ -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_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_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-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-cond)
add_cxx_compiler_flag_if_supported(OUR_FLAGS_OWN -Wduplicated-branches) add_cxx_compiler_flag_if_supported(OUR_FLAGS_OWN -Wduplicated-branches)
add_cxx_compiler_flag_if_supported(OUR_FLAGS_OWN -Wlogical-op) add_cxx_compiler_flag_if_supported(OUR_FLAGS_OWN -Wlogical-op)

View file

@ -298,7 +298,10 @@ bool CMapLayers::STileLayerVisuals::Init(unsigned int Width, unsigned int Height
{ {
m_Width = Width; m_Width = Width;
m_Height = Height; m_Height = Height;
if(Width == 0 || Height == 0 || Width >= std::numeric_limits<std::ptrdiff_t>::max() || Height >= std::numeric_limits<std::ptrdiff_t>::max()) if(Width == 0 || Height == 0)
return false;
if constexpr(sizeof(unsigned int) >= sizeof(ptrdiff_t))
if(Width >= std::numeric_limits<std::ptrdiff_t>::max() || Height >= std::numeric_limits<std::ptrdiff_t>::max())
return false; return false;
m_pTilesOfLayer = new CMapLayers::STileLayerVisuals::STileVisual[Height * Width]; m_pTilesOfLayer = new CMapLayers::STileLayerVisuals::STileVisual[Height * Width];