From 3fe92086f1bdde06eb3e9bd812fc19a279154458 Mon Sep 17 00:00:00 2001 From: Daviw Williams Date: Wed, 23 Oct 2013 16:33:42 +0200 Subject: [PATCH] Attempting to work around a GCC warning. --- .../include/PolyVoxCore/MaterialDensityPair.h | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/library/PolyVoxCore/include/PolyVoxCore/MaterialDensityPair.h b/library/PolyVoxCore/include/PolyVoxCore/MaterialDensityPair.h index 9f26b286..441318ba 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/MaterialDensityPair.h +++ b/library/PolyVoxCore/include/PolyVoxCore/MaterialDensityPair.h @@ -77,15 +77,19 @@ namespace PolyVox void setDensity(Type uDensity) { - POLYVOX_ASSERT(uDensity >= getMinDensity(), "Density out of range"); - POLYVOX_ASSERT(uDensity <= getMaxDensity(), "Density out of range"); + // Validate range of parameters. The casts are used to bypass a GCC warning 'comparison + // is always true due to limited range of data type' which is not helpful in this case. + POLYVOX_ASSERT(static_cast(uDensity) >= static_cast(getMinDensity()), "Density out of range"); + POLYVOX_ASSERT(static_cast(uDensity) <= static_cast(getMaxDensity()), "Density out of range"); m_uDensity = uDensity; } void setMaterial(Type uMaterial) { - POLYVOX_ASSERT(uMaterial >= 0, "Material out of range"); - POLYVOX_ASSERT(uMaterial <= (0x01 << NoOfMaterialBits) - 1, "Material out of range"); + // Validate range of parameters. The casts are used to bypass a GCC warning 'comparison + // is always true due to limited range of data type' which is not helpful in this case. + POLYVOX_ASSERT(static_cast(uMaterial) >= static_cast(0), "Material out of range"); + POLYVOX_ASSERT(static_cast(uMaterial) <= static_cast((0x01 << NoOfMaterialBits) - 1), "Material out of range"); m_uMaterial = uMaterial; }