1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-09 13:22:24 +03:00

0032903: Coding Rules - eliminate MSVC warning C26451 on VS2019/C++20

Put explicit type casting to avoid:
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).
This commit is contained in:
ddzama
2022-03-29 16:32:46 +03:00
committed by smoskvin
parent 9416ba5fb0
commit 4e1b5fcbf0
4 changed files with 28 additions and 23 deletions

View File

@@ -271,7 +271,7 @@ public: //! @name Preparation methods
if (!theName.IsEmpty())
{
myIsOwnName = true;
myName = (char* )Standard::Allocate (theName.Length() + 1);
myName = (char* )Standard::Allocate (Standard_Size(theName.Length()) + Standard_Size(1));
char* aName = (char* )myName;
memcpy (aName, theName.ToCString(), theName.Length());
aName[theName.Length()] = '\0';