1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-03 17:56:21 +03:00

0032495: Coding rules - eliminate CLang UndefinedBehaviorSanitizer warnings

- fixed CLang UndefinedBehaviorSanitizer warnings
This commit is contained in:
mkrylova 2021-07-28 09:32:34 +03:00 committed by bugmaster
parent e21db5b80e
commit 3016a39071
3 changed files with 78 additions and 105 deletions

View File

@ -3316,10 +3316,11 @@ int AdvApp2Var_ApproxF2var::mma2cdi_( integer *ndimen,
integer ilong;
intptr_t iofwr;
doublereal* wrkar = 0;
doublereal* wrkar_off;
integer iszwr;
integer ibb, ier = 0;
integer isz1, isz2, isz3, isz4;
intptr_t ipt1, ipt2, ipt3, ipt4;
intptr_t ipt1, ipt2, ipt3;
@ -3505,17 +3506,17 @@ int AdvApp2Var_ApproxF2var::mma2cdi_( integer *ndimen,
if (ier > 0) {
goto L9013;
}
ipt1 = iofwr;
ipt2 = ipt1 + isz1;
ipt3 = ipt2 + isz2;
ipt4 = ipt3 + isz3;
wrkar_off = reinterpret_cast<double*>(iofwr * sizeof(double));
ipt1 = isz1;
ipt2 = ipt1 + isz2;
ipt3 = ipt2 + isz3;
if (*iordru >= 0 && *iordru <= 2) {
/* --- Return 2*(IORDRU+1) coeff of 2*(IORDRU+1) polynoms of Hermite
--- */
AdvApp2Var_ApproxF2var::mma1her_(iordru, &wrkar[ipt1], iercod);
AdvApp2Var_ApproxF2var::mma1her_(iordru, wrkar_off, iercod);
if (*iercod > 0) {
goto L9100;
}
@ -3523,10 +3524,10 @@ int AdvApp2Var_ApproxF2var::mma2cdi_( integer *ndimen,
/* ---- Subract discretizations of polynoms of constraints
---- */
mma2cd3_(ndimen, nbpntu, &urootl[1], nbpntv, iordru, &sotbu1[1], &
sotbu2[1], &ditbu1[1], &ditbu2[1], &wrkar[ipt3], &wrkar[ipt1],
&sosotb[sosotb_offset], &soditb[soditb_offset], &disotb[
disotb_offset], &diditb[diditb_offset]);
mma2cd3_(ndimen, nbpntu, &urootl[1], nbpntv, iordru, &sotbu1[1],
&sotbu2[1], &ditbu1[1], &ditbu2[1], &wrkar_off[ipt2], wrkar_off,
&sosotb[sosotb_offset], &soditb[soditb_offset],
&disotb[disotb_offset], &diditb[diditb_offset]);
}
if (*iordrv >= 0 && *iordrv <= 2) {
@ -3534,7 +3535,7 @@ int AdvApp2Var_ApproxF2var::mma2cdi_( integer *ndimen,
/* --- Return 2*(IORDRV+1) coeff of 2*(IORDRV+1) polynoms of Hermite
--- */
AdvApp2Var_ApproxF2var::mma1her_(iordrv, &wrkar[ipt2], iercod);
AdvApp2Var_ApproxF2var::mma1her_(iordrv, &wrkar_off[ipt1], iercod);
if (*iercod > 0) {
goto L9100;
}
@ -3542,10 +3543,10 @@ int AdvApp2Var_ApproxF2var::mma2cdi_( integer *ndimen,
/* ---- Subtract discretisations of polynoms of constraint
---- */
mma2cd2_(ndimen, nbpntu, nbpntv, &vrootl[1], iordrv, &sotbv1[1], &
sotbv2[1], &ditbv1[1], &ditbv2[1], &wrkar[ipt4], &wrkar[ipt2],
&sosotb[sosotb_offset], &soditb[soditb_offset], &disotb[
disotb_offset], &diditb[diditb_offset]);
mma2cd2_(ndimen, nbpntu, nbpntv, &vrootl[1], iordrv, &sotbv1[1],
&sotbv2[1], &ditbv1[1], &ditbv2[1], &wrkar_off[ipt3], &wrkar_off[ipt1],
&sosotb[sosotb_offset], &soditb[soditb_offset],
&disotb[disotb_offset], &diditb[diditb_offset]);
}
/* --------------- Subtract constraints of corners ----------------
@ -3553,11 +3554,11 @@ int AdvApp2Var_ApproxF2var::mma2cdi_( integer *ndimen,
if (*iordru >= 0 && *iordrv >= 0) {
mma2cd1_(ndimen, nbpntu, &urootl[1], nbpntv, &vrootl[1], iordru,
iordrv, &contr1[contr1_offset], &contr2[contr2_offset], &
contr3[contr3_offset], &contr4[contr4_offset], &wrkar[ipt3], &
wrkar[ipt4], &wrkar[ipt1], &wrkar[ipt2], &sosotb[
sosotb_offset], &soditb[soditb_offset], &disotb[disotb_offset]
, &diditb[diditb_offset]);
iordrv, &contr1[contr1_offset], &contr2[contr2_offset],
&contr3[contr3_offset], &contr4[contr4_offset], &wrkar_off[ipt2],
&wrkar_off[ipt3], wrkar_off, &wrkar_off[ipt1],
&sosotb[sosotb_offset], &soditb[soditb_offset],
&disotb[disotb_offset], &diditb[diditb_offset]);
}
goto L9999;
@ -3630,10 +3631,11 @@ int AdvApp2Var_ApproxF2var::mma2ce1_(integer *numdec,
logical ldbg;
intptr_t iofwr;
doublereal* wrkar = 0;
doublereal* wrkar_off;
integer iszwr;
integer ier;
integer isz1, isz2, isz3, isz4, isz5, isz6, isz7;
intptr_t ipt1, ipt2, ipt3, ipt4, ipt5, ipt6, ipt7;
intptr_t ipt1, ipt2, ipt3, ipt4, ipt5, ipt6;
@ -3796,25 +3798,25 @@ int AdvApp2Var_ApproxF2var::mma2ce1_(integer *numdec,
iszwr = isz1 + isz2 + isz3 + isz4 + isz5 + isz6 + isz7;
AdvApp2Var_SysBase anAdvApp2Var_SysBase;
anAdvApp2Var_SysBase.mcrrqst_(&c__8, &iszwr, wrkar, &iofwr, &ier);
wrkar_off = reinterpret_cast<double*> (iofwr * sizeof(double));
if (ier > 0) {
goto L9013;
}
ipt1 = iofwr;
ipt2 = ipt1 + isz1;
ipt3 = ipt2 + isz2;
ipt4 = ipt3 + isz3;
ipt5 = ipt4 + isz4;
ipt6 = ipt5 + isz5;
ipt7 = ipt6 + isz6;
ipt1 = isz1;
ipt2 = ipt1 + isz2;
ipt3 = ipt2 + isz3;
ipt4 = ipt3 + isz4;
ipt5 = ipt4 + isz5;
ipt6 = ipt5 + isz6;
/* ----------------- Return Gauss coefficients of integration ----------------
*/
AdvApp2Var_ApproxF2var::mmapptt_(ndjacu, nbpntu, iordru, &wrkar[ipt1], iercod);
AdvApp2Var_ApproxF2var::mmapptt_(ndjacu, nbpntu, iordru, wrkar_off, iercod);
if (*iercod > 0) {
goto L9999;
}
AdvApp2Var_ApproxF2var::mmapptt_(ndjacv, nbpntv, iordrv, &wrkar[ipt2], iercod);
AdvApp2Var_ApproxF2var::mmapptt_(ndjacv, nbpntv, iordrv, &wrkar_off[ipt1], iercod);
if (*iercod > 0) {
goto L9999;
}
@ -3822,18 +3824,18 @@ int AdvApp2Var_ApproxF2var::mma2ce1_(integer *numdec,
/* ------------------- Return max polynoms of Jacobi ------------
*/
AdvApp2Var_ApproxF2var::mma2jmx_(ndjacu, iordru, &wrkar[ipt5]);
AdvApp2Var_ApproxF2var::mma2jmx_(ndjacv, iordrv, &wrkar[ipt6]);
AdvApp2Var_ApproxF2var::mma2jmx_(ndjacu, iordru, &wrkar_off[ipt5]);
AdvApp2Var_ApproxF2var::mma2jmx_(ndjacv, iordrv, &wrkar_off[ipt5]);
/* ------ Calculate the coefficients and their contribution to the error ----
*/
mma2ce2_(numdec, ndimen, nbsesp, &ndimse[1], ndminu, ndminv, ndguli,
ndgvli, ndjacu, ndjacv, iordru, iordrv, nbpntu, nbpntv, &epsapr[1]
, &sosotb[sosotb_offset], &disotb[disotb_offset], &soditb[
soditb_offset], &diditb[diditb_offset], &wrkar[ipt1], &wrkar[ipt2]
, &wrkar[ipt5], &wrkar[ipt6], &wrkar[ipt7], &wrkar[ipt3], &wrkar[
ipt4], &patjac[patjac_offset], &errmax[1], &errmoy[1], ndegpu,
ndgvli, ndjacu, ndjacv, iordru, iordrv, nbpntu, nbpntv, &epsapr[1],
&sosotb[sosotb_offset], &disotb[disotb_offset], &soditb[soditb_offset],
&diditb[diditb_offset], wrkar_off, &wrkar_off[ipt1],
&wrkar_off[ipt4], &wrkar_off[ipt5], &wrkar_off[ipt6], &wrkar_off[ipt2],
&wrkar_off[ipt3], &patjac[patjac_offset], &errmax[1], &errmoy[1], ndegpu,
ndegpv, itydec, iercod);
if (*iercod > 0) {
goto L9999;
@ -6167,6 +6169,7 @@ int AdvApp2Var_ApproxF2var::mma2fnc_(integer *ndimen,
integer ideb1, ibid1, ibid2, ncfja, ndgre, ilong,
ndwrk;
doublereal* wrkar = 0;
doublereal* wrkar_off;
integer nupil;
intptr_t iofwr;
doublereal uvpav[4] /* was [2][2] */;
@ -6177,7 +6180,7 @@ int AdvApp2Var_ApproxF2var::mma2fnc_(integer *ndimen,
integer ncb1;
doublereal eps3;
integer isz1, isz2, isz3, isz4, isz5;
intptr_t ipt1, ipt2, ipt3, ipt4, ipt5,iptt, jptt;
intptr_t ipt1, ipt2, ipt3, ipt4,iptt, jptt;
/* **********************************************************************
*/
@ -6427,19 +6430,19 @@ int AdvApp2Var_ApproxF2var::mma2fnc_(integer *ndimen,
ndwrk = isz1 + isz2 + isz3 + isz4 + isz5;
anAdvApp2Var_SysBase.mcrrqst_(&c__8, &ndwrk, wrkar, &iofwr, &ier);
wrkar_off = reinterpret_cast<double*>(iofwr * sizeof(double));
if (ier > 0) {
goto L9013; }
/* --> For the parameters of discretisation (NBROOT+2 extremities). */
ipt1 = iofwr;
/* --> For the points of discretisation FPNTAB(NDIMEN,NBROOT+2), */
/* FPNTAB(NBROOT,2*(IORDRE+1)) and for WRKAR of MMAPCMP. */
ipt2 = ipt1 + isz1;
ipt1 = isz1;
/* --> For the polynoms of Hermit */
ipt3 = ipt2 + isz2;
ipt2 = ipt1 + isz2;
/* --> For the Gauss coeff of integration. */
ipt4 = ipt3 + isz3;
ipt3 = ipt2 + isz3;
/* --> For the curve in Jacobi. */
ipt5 = ipt4 + isz4;
ipt4 = ipt3 + isz4;
/* ------------------ Initialisation of management of cuts ---------
*/
@ -6485,15 +6488,15 @@ L1000:
/* -------------------- Normalization of parameters -------------------- */
mma1nop_(nbroot, &rootlg[1], uvpav, isofav, &wrkar[ipt1], &ier);
mma1nop_(nbroot, &rootlg[1], uvpav, isofav, wrkar_off, &ier);
if (ier > 0) {
goto L9100;
}
/* -------------------- Discretisation of FONCNP ------------------------ */
mma1fdi_(ndimen, uvpav, foncnp, isofav, tconst, nbroot, &wrkar[ipt1],
iordre, ideriv, &wrkar[ipt2], &somtab[(ncb1 * somtab_dim2 + 1) *
mma1fdi_(ndimen, uvpav, foncnp, isofav, tconst, nbroot, wrkar_off,
iordre, ideriv, &wrkar_off[ipt1], &somtab[(ncb1 * somtab_dim2 + 1) *
somtab_dim1], &diftab[(ncb1 * diftab_dim2 + 1) * diftab_dim1], &
contr1[(ncb1 * contr1_dim2 + 1) * contr1_dim1 + 1], &contr2[(ncb1
* contr2_dim2 + 1) * contr2_dim1 + 1], iercod);
@ -6508,7 +6511,7 @@ L1000:
contr1_dim2 + 1) * contr1_dim1 + 1], &contr2[(ncb1 *
contr2_dim2 + 1) * contr2_dim1 + 1], &somtab[(ncb1 *
somtab_dim2 + 1) * somtab_dim1], &diftab[(ncb1 * diftab_dim2
+ 1) * diftab_dim1], &wrkar[ipt2], &wrkar[ipt3], &ier);
+ 1) * diftab_dim1], &wrkar_off[ipt1], &wrkar_off[ipt2], &ier);
if (ier > 0) {
goto L9100;
}
@ -6522,8 +6525,8 @@ L1000:
*/
mma1jak_(ndimen, nbroot, iordre, ndgjac, &somtab[(ncb1 * somtab_dim2 + 1)
* somtab_dim1], &diftab[(ncb1 * diftab_dim2 + 1) * diftab_dim1], &
wrkar[ipt4], &wrkar[ipt5], &ier);
* somtab_dim1], &diftab[(ncb1 * diftab_dim2 + 1) * diftab_dim1],
&wrkar_off[ipt3], &wrkar_off[ipt4], &ier);
if (ier > 0) {
goto L9100;
}
@ -6538,7 +6541,7 @@ L1000:
if (*iordre >= 0) {
mma1cnt_(ndimen, iordre, &contr1[(ncb1 * contr1_dim2 + 1) *
contr1_dim1 + 1], &contr2[(ncb1 * contr2_dim2 + 1) *
contr2_dim1 + 1], &wrkar[ipt3], ndgjac, &wrkar[ipt5]);
contr2_dim1 + 1], &wrkar_off[ipt2], ndgjac, &wrkar_off[ipt4]);
}
/* **********************************************************************
@ -6548,8 +6551,8 @@ L1000:
/* **********************************************************************
*/
mma1fer_(ndimen, nbsesp, &ndimse[1], iordre, ndgjac, &wrkar[ipt5], ncflim,
&epsapr[1], &wrkar[ipt2], &errmax[ncb1 * errmax_dim1 + 1], &
mma1fer_(ndimen, nbsesp, &ndimse[1], iordre, ndgjac, &wrkar_off[ipt4], ncflim,
&epsapr[1], &wrkar_off[ipt1], &errmax[ncb1 * errmax_dim1 + 1], &
errmoy[ncb1 * errmoy_dim1 + 1], &ncoeff[ncb1], &ier);
if (ier > 0) {
goto L9100;
@ -6577,26 +6580,26 @@ L1000:
AdvApp2Var_MathBase::mmapcmp_((integer*)ndimen,
&ncfja,
&ncoeff[ncb1],
&wrkar[ipt5],
&wrkar[ipt2]);
&wrkar_off[ipt4],
&wrkar_off[ipt1]);
/*pkv t*/
ilong = *ndimen * *ncflim;
AdvApp2Var_SysBase::mvriraz_(&ilong, &wrkar[ipt5]);
AdvApp2Var_SysBase::mvriraz_(&ilong, &wrkar_off[ipt4]);
/* -> Passage to canonic base (-1,1) (result in WRKAR(IPT5)).
*/
ndgre = ncoeff[ncb1] - 1;
i__1 = *ndimen;
for (nd = 1; nd <= i__1; ++nd) {
iptt = ipt2 + ((nd - 1) << 1) * (ndgre / 2 + 1);
jptt = ipt5 + (nd - 1) * ncoeff[ncb1];
AdvApp2Var_MathBase::mmjacan_(iordre, &ndgre, &wrkar[iptt], &wrkar[jptt]);
iptt = ipt1 + ((nd - 1) << 1) * (ndgre / 2 + 1);
jptt = ipt4 + (nd - 1) * ncoeff[ncb1];
AdvApp2Var_MathBase::mmjacan_(iordre, &ndgre, &wrkar_off[iptt], &wrkar_off[jptt]);
/* L400: */
}
/* -> Store the calculated curve */
ibid1 = 1;
AdvApp2Var_MathBase::mmfmca8_(&ncoeff[ncb1], ndimen, &ibid1, ncflim, ndimen, &ibid1, &
wrkar[ipt5], &courbe[(ncb1 * courbe_dim2 + 1) * courbe_dim1 +
AdvApp2Var_MathBase::mmfmca8_(&ncoeff[ncb1], ndimen, &ibid1, ncflim, ndimen, &ibid1,
&wrkar_off[ipt4], &courbe[(ncb1 * courbe_dim2 + 1) * courbe_dim1 +
1]);
/* -> Before normalization of constraints on (-1,1), recalculate */

View File

@ -115,11 +115,6 @@ int mcrgetv_(integer *sz,
intptr_t *iad,
integer *ier);
static
int mcrlocv_(void* t,
intptr_t *l);
static struct {
integer lec, imp, keyb, mae, jscrn, itblt, ibb;
} mblank__;
@ -383,9 +378,6 @@ int AdvApp2Var_SysBase::macrchk_()
/* Local variables */
integer i__, j;
intptr_t ioff;
doublereal* t = 0;
intptr_t loc;
/* ***********************************************************************
*/
@ -469,8 +461,6 @@ int AdvApp2Var_SysBase::macrchk_()
/* ----------------------------------------------------------------------*
*/
/* CALCULATE ADDRESS OF T */
mcrlocv_(t, &loc);
/* CONTROL OF FLAGS IN THE TABLE */
i__1 = mcrgene_.ncore;
for (i__ = 0; i__ < i__1; ++i__) {
@ -481,10 +471,9 @@ int AdvApp2Var_SysBase::macrchk_()
intptr_t* pp = p + j;
if (*pp != -1) {
ioff = (*pp - loc) / 8;
if (t[ioff] != -134744073.) {
double* t = reinterpret_cast<double*>(*pp);
if (*t != -134744073.)
{
/* MSG : '*** ERREUR : REMOVAL FROM MEMORY OF ADDRESS
E:',ICORE(J,I) */
/* AND OF RANK ICORE(12,I) */
@ -727,10 +716,7 @@ int macrgfl_(intptr_t *iadfld,
char cbid[1] = {};
integer ibid, ienr;
doublereal* t = 0;
integer novfl = 0;
intptr_t ioff,iadt;
/* ***********************************************************************
*/
@ -824,27 +810,25 @@ int macrgfl_(intptr_t *iadfld,
ifois = 1;
}
/* CALCULATE THE ADDRESS OF T */
mcrlocv_(t, &iadt);
/* CALCULATE THE OFFSET */
ioff = (*iadfld - iadt) / 8;
double* t = reinterpret_cast<double*>(*iadfld);
/* 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]);
}
/* UPDATE THE START FLAG */
t[ioff] = -134744073.;
*t = -134744073.;
/* FAKE CALL TO STOP THE DEBUGGER : */
macrbrk_();
/* UPDATE THE START FLAG */
ioff = (*iadflf - iadt) / 8;
t[ioff] = -134744073.;
t = reinterpret_cast<double*>(*iadflf);
*t = -134744073.;
/* FAKE CALL TO STOP THE DEBUGGER : */
macrbrk_();
@ -2076,7 +2060,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<intptr_t> (&dtab[ipre - 1]);
itab[(i__ << 2) - 1] = *iadr;
goto L9900;
}
@ -2270,7 +2254,7 @@ int AdvApp2Var_SysBase::mcrdelt_(integer *iunit,
/* SEARCH IN MCRGENE */
n = -1;
mcrlocv_(t, &loc);
loc = reinterpret_cast<intptr_t> (t);
for (i__ = mcrgene_.ncore - 1; i__ >= 0; --i__) {
if (*iunit == mcrgene_.icore[i__].unit && *isize ==
@ -2670,19 +2654,6 @@ int AdvApp2Var_SysBase::mcrlist_(integer *ier) const
return 0 ;
} /* mcrlist_ */
//=======================================================================
//function : mcrlocv_
//purpose :
//=======================================================================
int mcrlocv_(void* t,
intptr_t *l)
{
*l = reinterpret_cast<intptr_t> (t);
return 0 ;
}
//=======================================================================
//function : AdvApp2Var_SysBase::mcrrqst_
//purpose :
@ -2888,7 +2859,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<intptr_t> (t);
izu = ibyte + loc % *iunit;
irest = izu % 8;
if (irest != 0) {

View File

@ -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)