MantisBT
Mantis Bug Tracker Workflow

View Issue Details Jump to Notes ] Related Changesets ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0029165Open CASCADE[OCCT] OCCT:Visualizationpublic2017-09-29 19:012018-06-29 21:19
Reporterabv 
Assigned Tobugmaster 
PrioritynormalSeverityminor 
StatusclosedResolutionfixed 
PlatformOSOS Version
Product Version[OCCT] 7.2.0 
Target Version[OCCT] 7.3.0Fixed in Version[OCCT] 7.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
Attached Files

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

-  Notes
(0071075)
git (administrator)
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 (administrator)
2017-09-29 19:10

Branch CR29165 has been updated forcibly by abv.

SHA-1: 15a82f0ae62e87e60fb7b05d09ac05674bf0eae0
(0071080)
git (administrator)
2017-09-29 20:19

Branch CR29165 has been updated forcibly by abv.

SHA-1: ecb0f207374de0579706137e24d1172e5b7a6d1f
(0071092)
abv (manager)
2017-10-01 14:06

Fix is pushed to branch CR29165, please review
(0071094)
kgv (developer)
2017-10-01 16:22

Please test the patch.
(0071135)
bugmaster (administrator)
2017-10-03 09:40

Tested in framework of testing issue 29170
(0071474)
git (administrator)
2017-10-14 12:20

Branch CR29165 has been deleted by kgv.

SHA-1: ecb0f207374de0579706137e24d1172e5b7a6d1f

- Related Changesets
occt: master 03d960b8
Timestamp: 2017-09-29 16:04:13
Author: 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.
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 user533 Fixed in Version => 7.3.0
2018-06-29 21:19 user533 Status verified => closed


Copyright © 2000 - 2018 MantisBT Team
Powered by Mantis Bugtracker