Browse Source

Merge pull request #324 from Dmitry-Me/checkWithoutClangTautological

Range check without clang "always true" warning
Lee Thomason 11 years ago
parent
commit
a295da4302
1 changed files with 3 additions and 0 deletions
  1. 3 0
      tinyxml2.cpp

+ 3 - 0
tinyxml2.cpp

@@ -1958,6 +1958,9 @@ void XMLDocument::PrintError() const
             TIXML_SNPRINTF( buf2, LEN, "%s", _errorStr2 );
             TIXML_SNPRINTF( buf2, LEN, "%s", _errorStr2 );
         }
         }
 
 
+        // Should check INT_MIN <= _errorID && _errorId <= INT_MAX, but that
+        // causes a clang "always true" -Wtautological-constant-out-of-range-compare warning
+        TIXMLASSERT( 0 <= _errorID && XML_ERROR_COUNT - 1 <= INT_MAX );
         printf( "XMLDocument error id=%d '%s' str1=%s str2=%s\n",
         printf( "XMLDocument error id=%d '%s' str1=%s str2=%s\n",
                 static_cast<int>( _errorID ), ErrorName(), buf1, buf2 );
                 static_cast<int>( _errorID ), ErrorName(), buf1, buf2 );
     }
     }