View Issue Details

IDProjectCategoryView StatusLast Update
0029164Open CASCADEOCCT:Codingpublic2018-06-29 21:19
ReporterabvAssigned Tobugmaster  
PrioritynormalSeverityminor 
Status closedResolutionfixed 
Target Version7.3.0Fixed in Version7.3.0 
Summary0029164: GCC 7.1 compiler warnings -Wmaybe-uninitialized on gp_XYZ and siblings
DescriptionWhen OCCT is built with GCC 7.1 compiler (MinGw-64) it reports several warnings -Wmaybe-uninitialized in gp_XYZ and sibling classes.

While location of the problem is not properly reported by compiler, the reason is recognized: this is due to usage of local variables of reference type pointing to field of temporray object, like this:

Handle(Geom_Line) aLine = ...;
const gp_Dir& aDir = aLine->Lin().Direction();

Here Geom_Line::Lin() returns temporary object, and Direction() returns reference to its field. The object gets destroyed immediately (compiler has no knowledge of the fact that the value returned by Direction() is reference to field of that object). Thus aDir points to memory where destroyed object was located and which can be easily corrupted.
Steps To ReproduceBuild with GCC 7.1 (MinGW-64)
TagsNo tags attached.
Test case numberNot required

Activities

git

2017-09-29 18:35

administrator   ~0071073

Branch CR29164 has been created by abv.

SHA-1: 882dbc8cb1d8bbe1841467097457c9e243423c5f


Detailed log of new commits:

Author: abv
Date: Fri Sep 29 18:35:03 2017 +0300

    0029164: GCC 7.1 compiler warnings -Wmaybe-uninitialized in gp_XYZ and siblings
    
    Code is corrected to avoid local variables of reference type pointing to fields of temporary objects.

Author: kgv
Date: Thu Sep 28 21:29:22 2017 +0300

    0029152: Coding Rules - eliminate GCC compiler warnings -Wmisleading-indentation when using MinGW

git

2017-09-29 18:56

administrator   ~0071074

Branch CR29164 has been updated forcibly by abv.

SHA-1: e8701df9e5b08da1fa0eb02b939b976422ecba99

git

2017-09-29 19:09

administrator   ~0071076

Branch CR29164 has been updated forcibly by abv.

SHA-1: 72886751fde0a0aae0f1117a24d75d165ff369a2

git

2017-09-29 20:19

administrator   ~0071079

Branch CR29164 has been updated forcibly by abv.

SHA-1: 4e05f0aade0786ae27b8810747398b6015b60d0c

abv

2017-10-01 14:09

manager   ~0071093

Fix is pushed to CR29164, please review

kgv

2017-10-01 16:23

developer   ~0071095

Please test the patch.

bugmaster

2017-10-03 09:40

administrator   ~0071134

Tested in framework of testing issue 29170

git

2017-10-14 12:20

administrator   ~0071473

Branch CR29164 has been deleted by kgv.

SHA-1: 4e05f0aade0786ae27b8810747398b6015b60d0c

Related Changesets

occt: master 9b372aa8

2017-09-29 15:35:03

abv


Committer: bugmaster Details Diff
0029164: GCC 7.1 compiler warnings -Wmaybe-uninitialized in gp_XYZ and siblings

Code is corrected to avoid local variables of reference type pointing to fields of temporary objects.
Affected Issues
0029164
mod - src/AIS/AIS_EqualDistanceRelation.cxx Diff File
mod - src/BRepClass3d/BRepClass3d_SClassifier.cxx Diff File
mod - src/DrawDim/DrawDim_Distance.cxx Diff File
mod - src/TopOpeBRepTool/TopOpeBRepTool_GEOMETRY.cxx Diff File
mod - src/TopOpeBRepTool/TopOpeBRepTool_TOOL.cxx Diff File

Issue History

Date Modified Username Field Change
2017-09-29 18:17 abv New Issue
2017-09-29 18:17 abv Assigned To => kgv
2017-09-29 18:36 git Note Added: 0071073
2017-09-29 18:56 git Note Added: 0071074
2017-09-29 19:09 git Note Added: 0071076
2017-09-29 20:19 git Note Added: 0071079
2017-10-01 14:09 abv Note Added: 0071093
2017-10-01 14:09 abv Steps to Reproduce Updated
2017-10-01 14:24 abv Status new => resolved
2017-10-01 16:23 kgv Note Added: 0071095
2017-10-01 16:23 kgv Assigned To kgv => bugmaster
2017-10-01 16:23 kgv Status resolved => reviewed
2017-10-03 09:40 bugmaster Note Added: 0071134
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 9b372aa8
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: 0071473
2018-06-29 21:15 aiv Fixed in Version => 7.3.0
2018-06-29 21:19 aiv Status verified => closed