View Issue Details

IDProjectCategoryView StatusLast Update
0029165Open CASCADEOCCT:Visualizationpublic2018-06-29 21:19
ReporterabvAssigned Tobugmaster  
PrioritynormalSeverityminor 
Status closedResolutionfixed 
Product Version7.2.0 
Target Version7.3.0Fixed in Version7.3.0 
Summary0029165: Visualization - misuse of enumeration in Prs3d_DatumAspect
DescriptionWhen OCCT is built with GCC 7.1 compiler (MinGw-64), it reports warning "enum constant in boolean context" [-Wint-in-bool-context] in Prs3d_DatumAspect.

The code looks as follows:

void Prs3d_DatumAspect::SetDrawFirstAndSecondAxis (Standard_Boolean theToDraw)
{
  if (theToDraw)
  {
    myAxes = Prs3d_DatumAxes(myAxes | Prs3d_DA_XAxis | Prs3d_DA_YAxis);
  }
  else
  {
    myAxes = Prs3d_DatumAxes(myAxes & !Prs3d_DA_XAxis & !Prs3d_DA_YAxis);
  }
}

The expressions in parentheses yield integers. It is not correct to cast integer to enum, as it is not guaranteed to yield a valid value for that enum.

Here Prs3d_DatumAxes is enum with defined single bit values for X=1, Y=2, Z=4, and bit combinations XY, XZ, YZ, XYZ. The second assignment will yield zero if myAxes in the beginning equal to e.g. Prs3d_DA_XAxis. However, zero is not valid value for Prs3d_DatumAxes enum.
Steps To ReproduceBuild OCCT with GCC 7.1 (e.g. with MinGw-64)
TagsNo tags attached.
Test case numberNot required

Relationships

child of 0027958 closedbugmaster Visualization, AIS_Trihedron - add shaded presentation option 

Activities

git

2017-09-29 19:04

administrator   ~0071075

Branch CR29165 has been created by abv.

SHA-1: 6371d3788a5068ff0563af7c33c947596f102750


Detailed log of new commits:

Author: abv
Date: Fri Sep 29 19:04:13 2017 +0300

    0029165: Visualization - misuse of enumeration in Prs3d_DatumAspect
    
    Methods SetDrawFirstAndSecondAxis() and SetDrawThirdAxis() of the class Prs3d_DatumAspect are corrected to ensure that myAxis may be set only to valid values of the enum, and avoid unsafe operations.

git

2017-09-29 19:10

administrator   ~0071077

Branch CR29165 has been updated forcibly by abv.

SHA-1: 15a82f0ae62e87e60fb7b05d09ac05674bf0eae0

git

2017-09-29 20:19

administrator   ~0071080

Branch CR29165 has been updated forcibly by abv.

SHA-1: ecb0f207374de0579706137e24d1172e5b7a6d1f

abv

2017-10-01 14:06

manager   ~0071092

Fix is pushed to branch CR29165, please review

kgv

2017-10-01 16:22

developer   ~0071094

Please test the patch.

bugmaster

2017-10-03 09:40

administrator   ~0071135

Tested in framework of testing issue 29170

git

2017-10-14 12:20

administrator   ~0071474

Branch CR29165 has been deleted by kgv.

SHA-1: ecb0f207374de0579706137e24d1172e5b7a6d1f

Related Changesets

occt: master 03d960b8

2017-09-29 16:04:13

abv


Committer: bugmaster Details Diff
0029165: Visualization - misuse of enumeration in Prs3d_DatumAspect

Methods SetDrawFirstAndSecondAxis() and SetDrawThirdAxis() of the class Prs3d_DatumAspect are corrected to ensure that myAxis may be set only to valid values of the enum, and avoid unsafe operations.
Affected Issues
0029165
mod - src/Prs3d/Prs3d_DatumAspect.cxx Diff File

Issue History

Date Modified Username Field Change
2017-09-29 19:01 abv New Issue
2017-09-29 19:01 abv Assigned To => kgv
2017-09-29 19:04 git Note Added: 0071075
2017-09-29 19:10 git Note Added: 0071077
2017-09-29 20:17 kgv Relationship added child of 0027958
2017-09-29 20:17 kgv Product Version => 7.2.0
2017-09-29 20:19 git Note Added: 0071080
2017-10-01 14:06 abv Note Added: 0071092
2017-10-01 14:06 abv Status new => resolved
2017-10-01 14:06 abv Target Version 7.4.0 => 7.3.0
2017-10-01 16:22 kgv Note Added: 0071094
2017-10-01 16:22 kgv Assigned To kgv => bugmaster
2017-10-01 16:22 kgv Status resolved => reviewed
2017-10-03 09:40 bugmaster Note Added: 0071135
2017-10-03 09:40 bugmaster Status reviewed => tested
2017-10-03 09:52 bugmaster Test case number => Not required
2017-10-06 14:55 bugmaster Changeset attached => occt master 03d960b8
2017-10-06 14:55 bugmaster Status tested => verified
2017-10-06 14:55 bugmaster Resolution open => fixed
2017-10-14 12:20 git Note Added: 0071474
2018-06-29 21:15 aiv Fixed in Version => 7.3.0
2018-06-29 21:19 aiv Status verified => closed