MantisBT - Open CASCADE
View Issue Details
0029165Open CASCADE[OCCT] OCCT:Visualizationpublic2017-09-29 19:012018-06-29 21:19
abv 
bugmaster 
normalminor 
closedfixed 
[OCCT] 7.2.0 
[OCCT] 7.3.0[OCCT] 7.3.0 
Not required
0029165: Visualization - misuse of enumeration in Prs3d_DatumAspect
When 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.
Build OCCT with GCC 7.1 (e.g. with MinGw-64)
No tags attached.
child of 0027958closed bugmaster Visualization, AIS_Trihedron - add shaded presentation option 
Issue History
2017-09-29 19:01abvNew Issue
2017-09-29 19:01abvAssigned To => kgv
2017-09-29 19:04gitNote Added: 0071075
2017-09-29 19:10gitNote Added: 0071077
2017-09-29 20:17kgvRelationship addedchild of 0027958
2017-09-29 20:17kgvProduct Version => 7.2.0
2017-09-29 20:19gitNote Added: 0071080
2017-10-01 14:06abvNote Added: 0071092
2017-10-01 14:06abvStatusnew => resolved
2017-10-01 14:06abvTarget Version7.4.0 => 7.3.0
2017-10-01 16:22kgvNote Added: 0071094
2017-10-01 16:22kgvAssigned Tokgv => bugmaster
2017-10-01 16:22kgvStatusresolved => reviewed
2017-10-03 09:40bugmasterNote Added: 0071135
2017-10-03 09:40bugmasterStatusreviewed => tested
2017-10-03 09:52bugmasterTest case number => Not required
2017-10-06 14:55bugmasterChangeset attached => occt master 03d960b8
2017-10-06 14:55bugmasterStatustested => verified
2017-10-06 14:55bugmasterResolutionopen => fixed
2017-10-14 12:20gitNote Added: 0071474
2018-06-29 21:15aivFixed in Version => 7.3.0
2018-06-29 21:19aivStatusverified => closed

Notes
(0071075)
git   
2017-09-29 19:04   
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.
(0071077)
git   
2017-09-29 19:10   
Branch CR29165 has been updated forcibly by abv.

SHA-1: 15a82f0ae62e87e60fb7b05d09ac05674bf0eae0
(0071080)
git   
2017-09-29 20:19   
Branch CR29165 has been updated forcibly by abv.

SHA-1: ecb0f207374de0579706137e24d1172e5b7a6d1f
(0071092)
abv   
2017-10-01 14:06   
Fix is pushed to branch CR29165, please review
(0071094)
kgv   
2017-10-01 16:22   
Please test the patch.
(0071135)
bugmaster   
2017-10-03 09:40   
Tested in framework of testing issue 29170
(0071474)
git   
2017-10-14 12:20   
Branch CR29165 has been deleted by kgv.

SHA-1: ecb0f207374de0579706137e24d1172e5b7a6d1f