From: kgv Date: Wed, 28 Jul 2021 06:32:34 +0000 (+0300) Subject: 0032495: Coding rules - eliminate CLang UndefinedBehaviorSanitizer warnings X-Git-Url: http://git.dev.opencascade.org/gitweb/?a=commitdiff_plain;h=4111b91dc433391aa1ba3d81f16f41d68ebe5aeb;p=occt-copy.git 0032495: Coding rules - eliminate CLang UndefinedBehaviorSanitizer warnings --- diff --git a/src/AdvApp2Var/AdvApp2Var_SysBase.cxx b/src/AdvApp2Var/AdvApp2Var_SysBase.cxx index ec648a0779..688eb49998 100644 --- a/src/AdvApp2Var/AdvApp2Var_SysBase.cxx +++ b/src/AdvApp2Var/AdvApp2Var_SysBase.cxx @@ -115,9 +115,9 @@ int mcrgetv_(integer *sz, intptr_t *iad, integer *ier); -static +/*static int mcrlocv_(void* t, - intptr_t *l); + intptr_t *l);*/ static struct { @@ -383,9 +383,9 @@ int AdvApp2Var_SysBase::macrchk_() /* Local variables */ integer i__, j; - intptr_t ioff; - doublereal* t = 0; - intptr_t loc; + //intptr_t ioff; + //doublereal* t = NULL; + //intptr_t loc = 0; /* *********************************************************************** */ @@ -470,7 +470,7 @@ int AdvApp2Var_SysBase::macrchk_() */ /* CALCULATE ADDRESS OF T */ - mcrlocv_(t, &loc); + //loc = reinterpret_cast (t); // mcrlocv_ /* CONTROL OF FLAGS IN THE TABLE */ i__1 = mcrgene_.ncore; for (i__ = 0; i__ < i__1; ++i__) { @@ -481,10 +481,10 @@ int AdvApp2Var_SysBase::macrchk_() intptr_t* pp = p + j; if (*pp != -1) { - ioff = (*pp - loc) / 8; + double* t = reinterpret_cast(*pp); //ioff = (*pp - loc) / 8; - if (t[ioff] != -134744073.) { - + if (*t != -134744073.) //if (t[ioff] != -134744073.) + { /* MSG : '*** ERREUR : REMOVAL FROM MEMORY OF ADDRESS E:',ICORE(J,I) */ /* AND OF RANK ICORE(12,I) */ @@ -727,10 +727,10 @@ int macrgfl_(intptr_t *iadfld, char cbid[1] = {}; integer ibid, ienr; - doublereal* t = 0; + //doublereal* t = 0; integer novfl = 0; - intptr_t ioff,iadt; - + //intptr_t ioff = 0, iadt = 0; + /* *********************************************************************** */ @@ -825,26 +825,26 @@ int macrgfl_(intptr_t *iadfld, } /* CALCULATE THE ADDRESS OF T */ - mcrlocv_(t, &iadt); + //iadt = reinterpret_cast (t); // mcrlocv_ /* CALCULATE THE OFFSET */ - ioff = (*iadfld - iadt) / 8; + double* t = reinterpret_cast(*iadfld); //ioff = (*iadfld - iadt) / 8; /* SET TO OVERFLOW OF THE USER ZONE IN CASE OF PRODUCTION VERSION */ if (*iphase == 1 && novfl == 0) { ienr = *iznuti / 8; - maoverf_(&ienr, &t[ioff + 1]); + maoverf_(&ienr, &t[1]); //maoverf_(&ienr, &t[ioff + 1]); } /* UPDATE THE START FLAG */ - t[ioff] = -134744073.; + *t = -134744073.; //t[ioff] = -134744073.; /* FAKE CALL TO STOP THE DEBUGGER : */ macrbrk_(); /* UPDATE THE START FLAG */ - ioff = (*iadflf - iadt) / 8; - t[ioff] = -134744073.; + t = reinterpret_cast(*iadflf); //ioff = (*iadflf - iadt) / 8; + *t = -134744073.;//t[ioff] = -134744073.; /* FAKE CALL TO STOP THE DEBUGGER : */ macrbrk_(); @@ -2076,7 +2076,7 @@ int mcrcomm_(integer *kop, itab[(i__ << 2) - 4] = *noct / 8 + 1; itab[(i__ << 2) - 3] = ipre; itab[(i__ << 2) - 2] = *noct; - mcrlocv_(&dtab[ipre - 1], iadr); + *iadr = reinterpret_cast (&dtab[ipre - 1]); // mcrlocv_ itab[(i__ << 2) - 1] = *iadr; goto L9900; } @@ -2270,7 +2270,7 @@ int AdvApp2Var_SysBase::mcrdelt_(integer *iunit, /* SEARCH IN MCRGENE */ n = -1; - mcrlocv_(t, &loc); + loc = reinterpret_cast (t); // mcrlocv_ for (i__ = mcrgene_.ncore - 1; i__ >= 0; --i__) { if (*iunit == mcrgene_.icore[i__].unit && *isize == @@ -2675,13 +2675,13 @@ int AdvApp2Var_SysBase::mcrlist_(integer *ier) const //function : mcrlocv_ //purpose : //======================================================================= -int mcrlocv_(void* t, +/*int mcrlocv_(void* t, intptr_t *l) { *l = reinterpret_cast (t); return 0 ; -} +}*/ //======================================================================= //function : AdvApp2Var_SysBase::mcrrqst_ @@ -2888,7 +2888,7 @@ int AdvApp2Var_SysBase::mcrrqst_(integer *iunit, /* . add delta for alinement with the base */ /* . round to multiple of 8 above */ - mcrlocv_(t, &loc); + loc = reinterpret_cast (t); // mcrlocv_ izu = ibyte + loc % *iunit; irest = izu % 8; if (irest != 0) { diff --git a/src/NCollection/NCollection_Array1.hxx b/src/NCollection/NCollection_Array1.hxx index ce020eb035..97718aedb2 100644 --- a/src/NCollection/NCollection_Array1.hxx +++ b/src/NCollection/NCollection_Array1.hxx @@ -390,11 +390,10 @@ public: const Standard_Boolean theToCopyData) { Standard_RangeError_Raise_if (theUpper < theLower, "NCollection_Array1::Resize"); - const Standard_Integer anOldLen = Length(); - const Standard_Integer aNewLen = theUpper - theLower + 1; - const Standard_Integer aLowerOld = myLowerBound; + const Standard_Integer anOldLen = Length(); + const Standard_Integer aNewLen = theUpper - theLower + 1; - TheItemType* aBeginOld = &myData[aLowerOld]; + TheItemType* aBeginOld = myData != NULL ? &myData[myLowerBound] : NULL; myLowerBound = theLower; myUpperBound = theUpper; if (aNewLen == anOldLen)