View Issue Details

IDProjectCategoryView StatusLast Update
0028431Open CASCADEOCCT:Codingpublic2017-09-29 16:24
ReporterskiAssigned Toapn  
PrioritynormalSeverityminor 
Status closedResolutionfixed 
Product Version7.2.0 
Target Version7.2.0Fixed in Version7.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

Relationships

related to 0026937 closedapn Community Eliminate NO_CXX_EXCEPTION macro support 

Activities

git

2017-02-05 11:59

administrator   ~0063447

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

abv

2017-02-06 10:42

manager   ~0063454

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.

kgv

2017-02-06 10:47

developer   ~0063455

Please test the patch.

apn

2017-02-09 14:26

administrator   ~0063734

Last edited: 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%]

git

2017-03-20 14:35

administrator   ~0064503

Branch CR28431 has been deleted by inv.

SHA-1: d6d34b217ccce74afdc3ff57a340f7d0d7e01294

Related Changesets

occt: master f87817bc

2017-02-05 08:59:29

abv


Committer: apn Details Diff
0028431: Coding, Graphic3d - Eliminate GCC warning -Wstrict-overflow

Code amended to avoid warning issued by GCC optimizer
Affected Issues
0028431
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
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
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 aiv Fixed in Version => 7.2.0
2017-09-29 16:24 aiv Status verified => closed