View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0029170 | Open CASCADE | OCCT:Coding | public | 2017-09-30 21:05 | 2018-06-29 21:19 |
Reporter | Assigned To | bugmaster | |||
Priority | normal | Severity | minor | ||
Status | closed | Resolution | fixed | ||
Target Version | 7.3.0 | Fixed in Version | 7.3.0 | ||
Summary | 0029170: GCC 7.1 warnings -Wstrict-aliasing in Graphic3d_ArrayOfPrimitives.hxx | ||||
Description | When 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 Reproduce | Compile with GCC 7.1 (MinGW-64) | ||||
Tags | No tags attached. | ||||
Test case number | Not required | ||||
|
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). |
|
Branch CR29170 has been updated forcibly by abv. SHA-1: 215dbbde92b87dd5cd67f6019c48835339c1675d |
|
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. |
|
Please test the patch. |
|
Branch CR29170 has been updated forcibly by abv. SHA-1: c7e8ccd0841fe4d055d99f0b07a78a0f98807af2 |
|
Branch CR29170 has been updated forcibly by abv. SHA-1: 283f861cd437469319a3853072c5b832542adc78 |
|
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 |
|
Branch CR29170 has been deleted by kgv. SHA-1: 283f861cd437469319a3853072c5b832542adc78 |
occt: master 6a657c92 2017-09-30 18:35:05
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). |
Affected Issues 0029170 |
|
mod - src/Graphic3d/Graphic3d_ArrayOfPrimitives.hxx | Diff File | ||
mod - src/ViewerTest/ViewerTest_ObjectCommands.cxx | Diff File |
Date Modified | Username | Field | Change |
---|---|---|---|
2017-09-30 21:05 |
|
New Issue | |
2017-09-30 21:05 |
|
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 |
|
Note Added: 0071088 | |
2017-09-30 21:50 |
|
Status | new => resolved |
2017-09-30 21:50 |
|
Steps to Reproduce Updated | |
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 |
|
Note Edited: 0071088 | |
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 |
|
Fixed in Version | => 7.3.0 |
2018-06-29 21:19 |
|
Status | verified => closed |