]> OCCT Git - occt.git/commitdiff
0032916: Coding Rules - eliminate MSVS warning C26451 on VS2019/C++20 (Arithmetic...
authorddzama <ddzama@opencascade.com>
Thu, 31 Mar 2022 06:19:35 +0000 (09:19 +0300)
committersmoskvin <smoskvin@opencascade.com>
Fri, 8 Apr 2022 15:55:02 +0000 (18:55 +0300)
Microsoft Visual Studio Professional 2019
Version 16.11.11
std=c++20

Get rid of `Warning C26451 Arithmetic overflow: Using operator '+' on a 4 byte value
and then casting the result to a 8 byte value.
Cast the value to the wider type before calling operator '+' to avoid overflow (io.2)`

src/QANCollection/QANCollection_Stl.cxx

index c40c421e8d3bea1e958a2cf3fbaf899cb116d521..656fbbfdbd541d58a58068eedae82130d65cc079 100644 (file)
@@ -1115,7 +1115,7 @@ void TestPerformanceMapAccess(Draw_Interpretor& di)
     aTimer.Reset();
     aTimer.Start();
     {
-      for (Standard_Integer anIdx = 0; anIdx < 10000; ++anIdx)
+      for (size_t anIdx = 0; anIdx < 10000; ++anIdx)
       {
         if (aSet.find (aVec[anIdx + 1000]) == aSet.end())
           aResult = Standard_False;
@@ -1136,7 +1136,7 @@ void TestPerformanceMapAccess(Draw_Interpretor& di)
     aTimer.Reset();
     aTimer.Start();
     {
-      for (Standard_Integer anIdx = 0; anIdx < 10000; ++anIdx)
+      for (size_t anIdx = 0; anIdx < 10000; ++anIdx)
       {
         if (!aCollec->Contains (aVec[anIdx + 1000]))
           aResult = Standard_False;