random conditional jump in BRepLib.cxx tgtfaces()

Hello,

I think I found a bug in BRepLib.cxx in line 1587 (OCCT release 6.5.3):

the code line is the following:
if(ang >= angmax) angmax = ang;

In some circumstances ang is not initialized at this line because it will only be calculated if the variable Nok is true. I would suggest to change the code to
if(Nok && (ang >= angmax)) angmax = ang;

The bug affects the return value of the function and has probably a great impact. I am new to OCCT, so I don't know the internals very well. So maybe I am also wrong here.

Best regards, Martin

Pawel's picture

Hello Martin,

the variable 'ang' is declared as follows:

#ifndef DEB
Standard_Real ang =0.;
#else
Standard_Real ang;
#endif

which means it will be initialized to '0' only in Release mode. I think the initialization should rather look like this:

#ifdef DEB
Standard_Real ang =0.;
#else
Standard_Real ang;
#endif

because in the Release mode the compiler makes sure the variable is '0' any way (at least Visual Studio).

But in your case the Release version of OCCT should work OK.

Do you have a specific test case?

Pawel

Denis Barbier's picture

Hello,

There is some inconsistency between initializations of ang and angmax, IMHO ang should be initialized to -M_PI too.

By the way it would be much more simple to not use this DEB macro at all, it is almost useless in the whole OCCT source code.