MantisBT
Mantis Bug Tracker Workflow

View Issue Details Jump to Notes ] Related Changesets ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0029170Open CASCADE[OCCT] OCCT:Codingpublic2017-09-30 21:052018-06-29 21:19
Reporterabv 
Assigned Tobugmaster 
PrioritynormalSeverityminor 
StatusclosedResolutionfixed 
PlatformOSOS Version
Product Version 
Target Version[OCCT] 7.3.0Fixed in Version[OCCT] 7.3.0 
Summary0029170: GCC 7.1 warnings -Wstrict-aliasing in Graphic3d_ArrayOfPrimitives.hxx
DescriptionWhen OCCT is built with GCC 7.1 (with MinGw-64), it reports multiple warnings "dereferencing type-punned pointer will break strict aliasing rules [-Wstrict-aliasing]" in two methods Graphic3d_ArrayOfPrimitives::SetVertexColor().

The reason is that reinterpret_cast<> is used to cast pointers of types where both initial and target types are different from char*.
Steps To ReproduceCompile with GCC 7.1 (MinGW-64)
TagsNo tags attached.
Test case numberNot required
Attached Files

- Relationships

-  Notes
(0071086)
git (administrator)
2017-09-30 21:35

Branch CR29170 has been created by abv.

SHA-1: c44ce27fec1b39d4a8361a0ef1de67d779101855


Detailed log of new commits:

Author: abv
Date: Sat Sep 30 21:35:05 2017 +0300

    0029170: GCC 7.1 warnings -Wstrict-aliasing in Graphic3d_ArrayOfPrimitives.hxx
    
    Methods Graphic3d_ArrayOfPrimitives::SetVertexColor() accepting color as three double rgb values and Graphic3d_Vec4ub object are refactored to avoid using reinterpret_cast between pointers to complex types.
    
    Similar correction is made in ViewerTest_ObjectCommands.cxx (static function VDrawSphere).
(0071087)
git (administrator)
2017-09-30 21:36

Branch CR29170 has been updated forcibly by abv.

SHA-1: 215dbbde92b87dd5cd67f6019c48835339c1675d
(0071088)
abv (manager)
2017-09-30 21:50
edited on: 2017-10-01 13:58

Fix is is pushed to CR29170, please review.

Please note that method SetVertexColor (const Standard_Integer theIndex, const Standard_Integer theColor32), unlike other similar methods around, does not update myAttribs->NbElements at the end. Is that correct?

In general, the whole design of this class looks quite dangerous, as it operates directly with array of data which elements can have different content and size, without proper consistency checks. It is quite strange that methods like SetVertexColor behave differently in the case if index is out of range (exception is raised) and when either myAttribs data array is Null or data being set is not available (they do nothing).

It seems that this class should be redesigned as template, to make a choice of format of the stored data known at compile time, and enable static type checks. It conversion to template is not feasible, then it is not clear why so many large methods are implemented as inline -- they should rather be moved to CXX.

(0071089)
kgv (developer)
2017-09-30 21:54

Please test the patch.
(0071101)
git (administrator)
2017-10-01 21:13

Branch CR29170 has been updated forcibly by abv.

SHA-1: c7e8ccd0841fe4d055d99f0b07a78a0f98807af2
(0071104)
git (administrator)
2017-10-01 22:08

Branch CR29170 has been updated forcibly by abv.

SHA-1: 283f861cd437469319a3853072c5b832542adc78
(0071138)
bugmaster (administrator)
2017-10-03 09:47

Combination -
OCCT branch : CR29170 SHA-1: 283f861cd437469319a3853072c5b832542adc78
Products branch : master
was compiled on Linux, MacOS and Windows platforms and tested on optimize mode.

http://jenkins-test-10.nnov.opencascade.com/view/CR29152-master-abv/ [^]
http://jenkins-test-08.nnov.opencascade.com/view/CR29170_master/view/OCCT%20compile/ [^]

Number of compiler warnings:
Mingw 5 (151 master)

Regressions/Differences/Improvements:
No regressions/differences

CPU differences:
No differences that require special attention

Image differences :
No differences that require special attention

Memory differences :
No differences that require special attention
(0071476)
git (administrator)
2017-10-14 12:20

Branch CR29170 has been deleted by kgv.

SHA-1: 283f861cd437469319a3853072c5b832542adc78

- Related Changesets
occt: master 6a657c92
Timestamp: 2017-09-30 18:35:05
Author: abv
Committer: bugmaster
Details ] Diff ]
0029170: GCC 7.1 warnings -Wstrict-aliasing in Graphic3d_ArrayOfPrimitives.hxx

Methods Graphic3d_ArrayOfPrimitives::SetVertexColor() accepting color as three double rgb values and Graphic3d_Vec4ub object are refactored to avoid using reinterpret_cast between pointers to complex types.

Similar correction is made in ViewerTest_ObjectCommands.cxx (static function VDrawSphere).
mod - src/Graphic3d/Graphic3d_ArrayOfPrimitives.hxx Diff ] File ]
mod - src/ViewerTest/ViewerTest_ObjectCommands.cxx Diff ] File ]

- Issue History
Date Modified Username Field Change
2017-09-30 21:05 abv New Issue
2017-09-30 21:05 abv Assigned To => kgv
2017-09-30 21:35 git Note Added: 0071086
2017-09-30 21:36 git Note Added: 0071087
2017-09-30 21:50 abv Note Added: 0071088
2017-09-30 21:50 abv Status new => resolved
2017-09-30 21:50 abv Steps to Reproduce Updated View Revisions
2017-09-30 21:54 kgv Note Added: 0071089
2017-09-30 21:54 kgv Assigned To kgv => bugmaster
2017-09-30 21:54 kgv Status resolved => reviewed
2017-10-01 13:58 abv Note Edited: 0071088 View Revisions
2017-10-01 21:13 git Note Added: 0071101
2017-10-01 22:08 git Note Added: 0071104
2017-10-03 09:47 bugmaster Note Added: 0071138
2017-10-03 09:47 bugmaster Status reviewed => tested
2017-10-03 09:51 bugmaster Test case number => Not required
2017-10-06 14:55 bugmaster Changeset attached => occt master 6a657c92
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: 0071476
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