View Issue Details

IDProjectCategoryView StatusLast Update
0024167Open CASCADEOCCT:Modeling Algorithmspublic2013-12-19 13:58
ReporterabvAssigned Tobugmaster  
PrioritynormalSeverityminor 
Status closedResolutionfixed 
PlatformWindowsOSVC++ 2010 
Product Version6.7.0 
Target Version6.7.0Fixed in Version6.7.0 
Summary0024167: Compiler warnings 'unreacheable code' and 'conditional expression is constant' in MOA
DescriptionOn VC 2010 (RElease mode) with warning level 4 the following warnings are reported in modeling code:

Warning 9 warning C4702: unreachable code d:\occt\src\brepcheck\brepcheck_face.cxx 662 TKTopAlgo
Warning 10 warning C4702: unreachable code d:\occt\src\brepclass3d\brepclass3d.cxx 121 TKTopAlgo
Warning 13 warning C4702: unreachable code d:\occt\src\boptools\boptools_algotools3d.cxx 786 TKBO
Warning 15 warning C4702: unreachable code d:\occt\src\brepalgo\brepalgo_facerestrictor.cxx 264 TKBool

Warning 29 warning C4702: unreachable code d:\occt\src\qanewmodtopope\qanewmodtopope_glue_wire.cxx 982 TKQADraw

Warning 2 warning C4127: conditional expression is constant D:\occt\src\math\math_FunctionRoots.cxx 227 TKMath
Warning 3 warning C4127: conditional expression is constant D:\occt\src\math\math_FunctionRoots.cxx 495 TKMath
Warning 4 warning C4127: conditional expression is constant D:\occt\src\math\math_FunctionRoots.cxx 506 TKMath
Warning 5 warning C4127: conditional expression is constant D:\occt\src\math\math_FunctionRoots.cxx 980 TKMath
Warning 6 warning C4127: conditional expression is constant D:\occt\inc\IntCurveSurface_Polyhedron.gxx 198 TKGeomAlgo
Warning 7 warning C4127: conditional expression is constant D:\occt\inc\IntCurveSurface_Polyhedron.gxx 289 TKGeomAlgo
Warning 16 warning C4127: conditional expression is constant D:\occt\src\ChFi3d\ChFi3d_Builder_C1.cxx 1254 TKFillet
Warning 17 warning C4127: conditional expression is constant D:\occt\src\ChFi3d\ChFi3d_Builder_C1.cxx 1379 TKFillet
Warning 18 warning C4127: conditional expression is constant D:\occt\src\ChFi3d\ChFi3d_Builder_C1.cxx 1389 TKFillet

In addition, in Debug mode:

Warning 6 warning C4127: conditional expression is constant D:\occt\src\BRepTools\BRepTools_GTrsfModification.cxx 126 TKBRep
Warning 7 warning C4127: conditional expression is constant D:\occt\src\BRepTools\BRepTools_GTrsfModification.cxx 174 TKBRep
TagsNo tags attached.
Test case numberNot needed

Relationships

related to 0023947 closedomy Eliminate trivial compiler warnings in MSVC++ with warning level 4 
parent of 0024222 closedbugmaster Compiler warnings 'unreacheable code' and 'conditional expression is constant' in MOA 

Activities

aml

2013-09-19 14:43

developer   ~0025653

Dear ifv,
Please, test the current state of branch CR24167 to be sure it is still OK.

ifv

2013-09-19 15:41

developer   ~0025655

I think that it is better in BRepTools_GTrsfModification
replace
Standard_NoSuchObject_Raise_if(1,"BRepTools_GTrsfModification : Pb no BSpline/Bezier Type Surface");
directly by

Standard_NoSuchObject::Raise(MESSAGE);

instead of your suggestion

Standard_Boolean messageFlag = 1;
      Standard_NoSuchObject_Raise_if(messageFlag,"BRepTools_GTrsfModification : Pb no BSpline/Bezier Type Surface");

aml

2013-09-20 13:10

developer   ~0025672

Dear ifv,

I implemented your suggestions, please re-check code in branch CR24167.

ifv

2013-09-20 13:21

developer   ~0025673

Ok

kgv

2013-09-20 14:27

developer   ~0025675

Dear aml,

-  for (i=1; i<=aNbDomains; ++i) {
+  for (i=1; i<=aNbDomains; /*++i*/) {

-       exp.Next()) {
+       /*exp.Next()*/) {

-  for (; aIt.More(); aIt.Next()) {
+  for (; aIt.More(); /*aIt.Next()*/) {

If all this loops have been designed to read only first value - please change them to "if" statements instead of commenting code.

-    const Standard_Boolean variant1 = Standard_True;
+    //const Standard_Boolean variant1 = Standard_True;

-static const Standard_Integer methode = 1;  //-- 1:(Nv Traitement)  3:(Nv + Ancien +check)  2:(Ancien) 
+//static const Standard_Integer methode = 1;  //-- 1:(Nv Traitement)  3:(Nv + Ancien +check)  2:(Ancien) 

Please do not leave dead code in commented state - remove it.

+#define NEWCODE
+//#define OLDCODE
+//#define CHECK

I consider new macros should have more descriptive names - at least prefixed with local name to avoid theoretical name collisions.

aml

2013-09-20 15:30

developer   ~0025676

Dear ifv,
Please check current state of branch CR24167 according to new notes.

ifv

2013-09-20 16:43

developer   ~0025679

in BOPTools_AlgoTools3D.cxx

if (aNbDomains == 1) {

must be

if (aNbDomains > 0) {

Algorithm uses only first Domain, but there can be some Domains.

if(aNbDomains == 0) it is necessary return error code the same as for case when Hatcher is not done:

if (!bIsDone) { iErr=2; return iErr; }

Remove unnecessary "break" (line 806)

In BRepAlgo_FaceRestrictor.cxx

exp.Init(wir,TopAbs_EDGE);
if (!exp.Current().IsNull()) {
it is better
if(exp.More()) {

exp.Current() raises exception if !exp.More()

BRepCheck_Face.cxx, BRepClass3d.cxx - the same as above.

aml

2013-09-20 17:26

developer   ~0025682

Dear ifv,

I implemented your suggestions, please re-check code in branch CR24167.

ifv

2013-09-23 09:58

developer   ~0025693

in BOPTools_AlgoTools3D.cxx checking
....
else if (aNbDomains == 0) {

is not necessary
It is enough:
if(aNbDomains > 0) {
  Correct case
}
else
{
  Error
}

aml

2013-09-23 10:22

developer   ~0025696

dear ifv,
I implemented your corrections please check branch CR24167.

ifv

2013-09-27 10:19

developer   ~0025764

Ok

mkv

2013-09-30 15:48

tester   ~0025795

Dear BugMaster,

Branch CR24167 (and products from GIT master) was compiled on Linux and Windows platforms and tested.
SHA-1: bcc017d830857839c1954085a55990711d2636a7

Number of compiler warnings:

occt component :
Linux: 506 (506 on master)
Windows: 20 (31 on master)

products component :
Linux: 190 (190 on master)
Windows: 287 (287 on master)

Regressions:
No regressions

Improvements:
No improvements

Testing cases:
Not needed

Testing on Linux:
Total MEMORY difference: 366373524 / 366214652
Total CPU difference: 43783.69000000105 / 42280.380000000965

Testing on Windows:
Total MEMORY difference: 428752700 / 429010728
Total CPU difference: 47344.75 / 48288.609375

There are not differences in images found by testdiff.

abv

2013-10-04 14:32

manager   ~0025897

Pardon, why warnings in qanewmodtopope_glue_wire.cxx and IntCurveSurface_Polyhedron.gxx have not been fixed?!

ifv

2013-10-04 14:39

developer   ~0025898

Dear Alexander, probably you missed two cases.
Please fix.

aml

2013-10-04 14:44

developer   ~0025899

Yes, it's my fault. I forgot about this files.

abv

2013-10-04 14:58

manager   ~0025901

Alexander, please register separate issue for fixing remaining files (make it a child of this one). Besides, please be careful fixing GXX files: you can easily modify the file located in inc folder instead of the one located in src.

abv

2013-10-04 15:17

manager   ~0025904

Igor, please switch this issue back to Verified: the remaining will be fixed in context of 0024222

Related Changesets

occt: master 3ed30348

2013-10-03 10:07:10

aml


Committer: bugmaster Details Diff
0024167: Compiler warnings 'unreacheable code' and 'conditional expression is constant' in MOA

Resolved some C4702 (unreachable code) and C4127 (conditional expression is constant).

small corrections in NoSuchObject invoking.

Macros names changing, deadcode deleting, re-writing "for" loops into equivalent "if" structures.

changed condition in "if" block, deadcode deleted.

Small changes in else statement.
Affected Issues
0024167
mod - src/BOPTools/BOPTools_AlgoTools3D.cxx Diff File
mod - src/BRepAlgo/BRepAlgo_FaceRestrictor.cxx Diff File
mod - src/BRepCheck/BRepCheck_Face.cxx Diff File
mod - src/BRepClass3d/BRepClass3d.cxx Diff File
mod - src/BRepTools/BRepTools_GTrsfModification.cxx Diff File
mod - src/ChFi3d/ChFi3d_Builder_C1.cxx Diff File
mod - src/math/math_FunctionRoots.cxx Diff File

Issue History

Date Modified Username Field Change
2013-09-12 16:46 abv New Issue
2013-09-12 16:46 abv Assigned To => ifv
2013-09-12 17:01 abv Relationship added related to 0023947
2013-09-12 17:13 abv Description Updated
2013-09-13 08:49 abv Status new => assigned
2013-09-16 16:54 ifv Assigned To ifv => aml
2013-09-19 14:43 aml Note Added: 0025653
2013-09-19 14:43 aml Assigned To aml => ifv
2013-09-19 14:43 aml Status assigned => resolved
2013-09-19 15:41 ifv Note Added: 0025655
2013-09-19 15:41 ifv Assigned To ifv => aml
2013-09-19 15:41 ifv Status resolved => feedback
2013-09-20 13:10 aml Note Added: 0025672
2013-09-20 13:10 aml Assigned To aml => ifv
2013-09-20 13:10 aml Status feedback => resolved
2013-09-20 13:21 ifv Note Added: 0025673
2013-09-20 13:21 ifv Status resolved => reviewed
2013-09-20 14:27 kgv Note Added: 0025675
2013-09-20 14:27 kgv Assigned To ifv => aml
2013-09-20 14:27 kgv Status reviewed => assigned
2013-09-20 15:30 aml Note Added: 0025676
2013-09-20 15:30 aml Assigned To aml => ifv
2013-09-20 15:30 aml Status assigned => resolved
2013-09-20 16:43 ifv Note Added: 0025679
2013-09-20 16:43 ifv Status resolved => feedback
2013-09-20 17:26 aml Note Added: 0025682
2013-09-20 17:26 aml Status feedback => resolved
2013-09-23 09:58 ifv Note Added: 0025693
2013-09-23 09:58 ifv Status resolved => feedback
2013-09-23 09:59 ifv Assigned To ifv => aml
2013-09-23 10:22 aml Note Added: 0025696
2013-09-23 10:22 aml Assigned To aml => ifv
2013-09-23 10:22 aml Status feedback => resolved
2013-09-27 10:19 ifv Note Added: 0025764
2013-09-27 10:19 ifv Status resolved => reviewed
2013-09-27 13:33 mkv Test case number => Not needed
2013-09-27 13:33 mkv Assigned To ifv => mkv
2013-09-30 15:48 mkv Note Added: 0025795
2013-09-30 15:48 mkv Assigned To mkv => bugmaster
2013-09-30 15:48 mkv Status reviewed => tested
2013-10-04 12:48 bugmaster Changeset attached => occt master 3ed30348
2013-10-04 12:48 bugmaster Status tested => verified
2013-10-04 12:48 bugmaster Resolution open => fixed
2013-10-04 14:32 abv Note Added: 0025897
2013-10-04 14:38 ifv Assigned To bugmaster => aml
2013-10-04 14:39 ifv Note Added: 0025898
2013-10-04 14:39 ifv Status verified => feedback
2013-10-04 14:39 ifv Resolution fixed => reopened
2013-10-04 14:44 aml Note Added: 0025899
2013-10-04 14:58 abv Note Added: 0025901
2013-10-04 15:06 aml Relationship added parent of 0024222
2013-10-04 15:16 abv Assigned To aml => bugmaster
2013-10-04 15:17 abv Note Added: 0025904
2013-10-04 15:37 bugmaster Status feedback => tested
2013-10-04 15:37 bugmaster Status tested => verified
2013-10-04 15:37 bugmaster Resolution reopened => fixed
2013-12-19 13:51 bugmaster Status verified => closed
2013-12-19 13:58 bugmaster Fixed in Version => 6.7.0