MantisBT
Mantis Bug Tracker Workflow

View Issue Details Jump to Notes ] Related Changesets ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0028431Open CASCADE[OCCT] OCCT:Codingpublic2017-02-03 13:072017-09-29 16:24
Reporterski 
Assigned Toapn 
PrioritynormalSeverityminor 
StatusclosedResolutionfixed 
PlatformOSOS Version
Product Version[OCCT] 7.2.0 
Target Version[OCCT] 7.2.0Fixed in Version[OCCT] 7.2.0 
Summary0028431: Coding, Graphic3d - Eliminate GCC warning -Wstrict-overflow
DescriptionWarning -Wstrict-overflow appears in file occt/src/Graphic3d/Graphic3d_ArrayOfPrimitives.cxx.

Assuming signed overflow does not occur when assuming that (X + c) >= X is always true [-Wstrict-overflow]

Graphic3d_ArrayOfPrimitives.cxx:165
Graphic3d_ArrayOfPrimitives.cxx:195
Graphic3d_ArrayOfPrimitives.cxx:227
Graphic3d_ArrayOfPrimitives.cxx:241


Reproduced only on next platforms:
• Fedora22-64 (gcc 5.3.1)
• Ubuntu-1604-64 (gcc 5.4.0)
Steps To ReproduceBuild with GCC 5.2
TagsNo tags attached.
Test case numberNot needed
Attached Files

- Relationships
related to 0026937closedapn Community Eliminate NO_CXX_EXCEPTION macro support 

-  Notes
(0063447)
git (administrator)
2017-02-05 11:59

Branch CR28431 has been created by abv.

SHA-1: d6d34b217ccce74afdc3ff57a340f7d0d7e01294


Detailed log of new commits:

Author: abv
Date: Sun Feb 5 11:59:29 2017 +0300

    0028431: Coding, Graphic3d - Eliminate GCC warning -Wstrict-overflow
    
    Code amended to avoid warning issued by GCC optimizer
(0063454)
abv (manager)
2017-02-06 10:42

Apparently the reason of the warning is specific combination of operations with counter:

- In Graphic3d_ArrayOfPrimitives::AddVertex():

> const Standard_Integer anIndex = myAttribs->NbElements + 1;
> SetVertice (anIndex, theX, theY, theZ);

- Then, in inline Graphic3d_ArrayOfPrimitives::SetVertice()

> myAttribs->NbElements = Max (theIndex, myAttribs->NbElements);

Here GCC apparently is able to detect that theIndex is myAttribs->NbElements+1, and assume that no integer overflow occurs and thus theIndex is always greater than myAttribs->NbElements. The warning just says "hey, I assume that no overflow occurs and optimize the code such that it can work differently than what literally coded (in case of overflow)".

Replacing use of "Max" by "if" seems to fix the issue.

Fix pushed to CR28431, please review.
(0063455)
kgv (developer)
2017-02-06 10:47

Please test the patch.
(0063734)
apn (administrator)
2017-02-09 14:26
edited on: 2017-02-09 14:27

Dear BugMaster,

Branch CR28431 from occt git-repository (and master from products git-repository) was compiled on Linux, MacOS and Windows platforms and tested.
SHA-1: d6d34b217ccce74afdc3ff57a340f7d0d7e01294

Number of compiler warnings:
occt component:
   Linux: 0 (0 on master)
   Windows: 0 (0 on master)
   MasOS: 0 (0 on master)
   Fedora22-64: 0
   Ubuntu-1604-64: 0
products component:
   Linux: 64
   Windows: 0
   MacOS: 1201

Regressions/Differences:
Not detected

Testing cases:
Not needed

Testing on Linux:
Total MEMORY difference: 92039342 / 91275124 [+0.84%]
Total CPU difference: 19690.200000000386 / 19662.570000000327 [+0.14%]

Testing on Windows:
Total MEMORY difference: 57123763 / 57124391 [-0.00%]
Total CPU difference: 18044.05846629865 / 18512.045866198645 [-2.53%]

(0064503)
git (administrator)
2017-03-20 14:35

Branch CR28431 has been deleted by inv.

SHA-1: d6d34b217ccce74afdc3ff57a340f7d0d7e01294

- Related Changesets
occt: master f87817bc
Timestamp: 2017-02-05 08:59:29
Author: abv
Committer: apn
Details ] Diff ]
0028431: Coding, Graphic3d - Eliminate GCC warning -Wstrict-overflow

Code amended to avoid warning issued by GCC optimizer
mod - src/Graphic3d/Graphic3d_ArrayOfPrimitives.lxx Diff ] File ]

- Issue History
Date Modified Username Field Change
2017-02-03 13:07 ski New Issue
2017-02-03 13:07 ski Assigned To => abv
2017-02-03 13:18 ski Relationship added related to 0026937
2017-02-05 11:59 git Note Added: 0063447
2017-02-06 10:42 abv Note Added: 0063454
2017-02-06 10:42 abv Assigned To abv => kgv
2017-02-06 10:42 abv Status new => resolved
2017-02-06 10:42 abv Steps to Reproduce Updated View Revisions
2017-02-06 10:47 kgv Note Added: 0063455
2017-02-06 10:47 kgv Assigned To kgv => bugmaster
2017-02-06 10:47 kgv Status resolved => reviewed
2017-02-06 10:47 kgv Product Version => 7.2.0
2017-02-06 16:57 apn Test case number => Not needed
2017-02-06 16:57 apn Assigned To bugmaster => apn
2017-02-09 14:26 apn Note Added: 0063734
2017-02-09 14:27 apn Note Edited: 0063734 View Revisions
2017-02-09 14:28 apn Assigned To apn => bugmaster
2017-02-09 14:28 apn Status reviewed => tested
2017-02-10 14:33 apn Changeset attached => occt master f87817bc
2017-02-10 14:33 apn Assigned To bugmaster => apn
2017-02-10 14:33 apn Status tested => verified
2017-02-10 14:33 apn Resolution open => fixed
2017-03-20 14:35 git Note Added: 0064503
2017-09-29 16:20 user533 Fixed in Version => 7.2.0
2017-09-29 16:24 user533 Status verified => closed


Copyright © 2000 - 2018 MantisBT Team
Powered by Mantis Bugtracker