MantisBT
Mantis Bug Tracker Workflow

View Issue Details Jump to Notes ] Related Changesets ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0028355Community[OCCT] OCCT:Foundation Classespublic2017-01-13 18:342017-09-29 16:24
ReporterBenjaminBihler 
Assigned Toapn 
PrioritynormalSeverityminor 
StatusclosedResolutionfixed 
PlatformLinuxOSDebian 6.0OS Version64 bit
Product Version[OCCT] 7.1.0 
Target Version[OCCT] 7.2.0Fixed in Version[OCCT] 7.2.0 
Summary0028355: Stating wrong parent class in DEFINE_STANDARD_RTTIEXT is not recognized during compilation
DescriptionIt is necessary to give always the direct parent class as second argument of the macro. If this is not done correctly, the code compiles, but there are runtime problems with RTTI (like wrong behaviour of IsKind() method).

At least with g++ from version 4.3 on there seems to be a possibility to do a static assert to check the correct base class during compile time.
Steps To ReproduceNot required
TagsNo tags attached.
Test case numberNot needed
Attached Files

- Relationships

-  Notes
(0062596)
git (administrator)
2017-01-13 19:40

Branch CR28355 has been created by BenjaminBihler.

SHA-1: 9f02e75fa9348a3a28db0ce7faf8fc6c0f2589c5


Detailed log of new commits:

Author: Benjamin Bihler
Date: Fri Jan 13 17:40:33 2017 +0100

    0028355: Stating wrong parent class in DEFINE_STANDARD_RTTIEXT is not recognized during compilation
    
    Fixed dubious RTTI definitions.

Author: Benjamin Bihler
Date: Fri Jan 13 17:24:18 2017 +0100

    0028355: Stating wrong parent class in DEFINE_STANDARD_RTTIEXT is not recognized during compilation
    
    Added static_assert for GCC compiler from version 4.3 on.
(0062618)
git (administrator)
2017-01-16 11:45

Branch CR28355 has been updated by BenjaminBihler.

SHA-1: e6c2d62c6a93ceee2e652539849128146adc83f2


Detailed log of new commits:

Author: Benjamin Bihler
Date: Mon Jan 16 09:44:25 2017 +0100

    0028355: Stating wrong parent class in DEFINE_STANDARD_RTTIEXT is not recognized during compilation
    
    Improved error message (classes can have more than one direct parent class).

(0062620)
git (administrator)
2017-01-16 11:49

Branch CR28355 has been updated by BenjaminBihler.

SHA-1: 08b3a7f398238b29f11fa557b8babfc24efb96c3


Detailed log of new commits:

Author: Benjamin Bihler
Date: Mon Jan 16 09:49:13 2017 +0100

    0028355: Stating wrong parent class in DEFINE_STANDARD_RTTIEXT is not recognized during compilation
    
    Fixed macro definition for non-GNU-compilers.

(0062624)
git (administrator)
2017-01-16 13:48

Branch CR28355_2 has been created by abv.

SHA-1: 6f8f71e35e541fb29fda3d0135567fbc6cd5459b


Detailed log of new commits:

Author: Benjamin Bihler
Date: Fri Jan 13 19:24:18 2017 +0300

    0028355: Stating wrong parent class in DEFINE_STANDARD_RTTIEXT is not recognized during compilation
    
    Added compile-time check (static_assert) to ensure that classes used in DEFINE_STANDARD_RTTI* macros are actually derived and base class.
    For GCC compiler version 4.3 and later on, check ensures that base is direct.
    
    Fixed dubious RTTI definitions.
(0062625)
BenjaminBihler (developer)
2017-01-16 13:54

The duplicate is invisible for me. :-(
(0062630)
abv (manager)
2017-01-16 14:41
edited on: 2017-01-16 14:41

Hello Benjamin,

You do not see the duplicate because it is created inside customer project; this does not make any difference though because the matter is exactly the same, and nothing has been done for that before your fix.

Please have a look at reworked fix in branch CR28355_2: I have added similar check for non-GCC compilers, and revised a bit implementation (moved auxiliar types to namespace "opencascade", added details in error message etc.).

I am now checking that it works under MS VC compilers, and will submit for certification testing as soon as the check is done. If you could check that version in your environment, it would be great.

(0062635)
BenjaminBihler (developer)
2017-01-16 16:20

G++ compilation fails with "error: a template declaration cannot appear at block scope". Since static assertions are done at compile time there is no reason to put OCC_CHECK_BASE_CLASS inside the get_type_name implementation, is there? Therefore it should be moved outside, then compilation with g++ will succeed.
(0062636)
git (administrator)
2017-01-16 16:21

Branch CR28355_2 has been updated by BenjaminBihler.

SHA-1: 592218578500f6fd33cea66a9d25b0799fe0a4ee


Detailed log of new commits:

Author: Benjamin Bihler
Date: Mon Jan 16 13:59:42 2017 +0100

    0028355: Stating wrong parent class in DEFINE_STANDARD_RTTIEXT is not recognized during compilation
    
    Fixed compilation with g++.

(0062650)
abv (manager)
2017-01-16 18:28

Sorry for delay.. Unfortunately, std::is_base_of<> (used in OCC_CHECK_BASE_CLASS macro for non-GCC) cannot be used inside the class definition (error "class is not completely defined"). This is a reason why I put it inside the function. I see the problem with GCC, will try to fix it in compatible way.
(0062652)
BenjaminBihler (developer)
2017-01-16 18:38

I see. In one of my first tries I had the same problem. There I put the check into IMPLEMENT_STANDARD_RTTIEXT. Is this an option? (Unfortunately the error message appears not exactly at the position of the problem then, but anyway it's easy to find it.)
(0062659)
git (administrator)
2017-01-16 20:43

Branch CR28355_2 has been updated by abv.

SHA-1: 53ebf590e8b6ab2054f1aecb3e3e700a378f7dd5


Detailed log of new commits:

Author: abv
Date: Mon Jan 16 20:43:09 2017 +0300

    // correction for non-GCC compilers

(0062664)
git (administrator)
2017-01-16 22:41

Branch CR28355_2 has been updated by abv.

SHA-1: eb936106766946b6ba652d4b7cf2f40b3ce0fd65


Detailed log of new commits:

Author: abv
Date: Mon Jan 16 22:41:37 2017 +0300

    Added static assert to ensure that first argument of macro DEFINE_STANDARD_RTTI* actually corresponds to current class being defined.

(0062665)
abv (manager)
2017-01-17 07:09

Benjamin, putting the check to IMPLEMENT_STANDARD_RTTIEXT is not an option, since we have also fully inlined macro DEFINE_STANDARD_RTTI_INLINE which shall be protected as well for the fix to be completed. The issue with GCC is just that "using" statement for declaring template cannot be used inside function; this can be easily avoided. See the updated branch.

Note that I have added one more assert, to check that the class being defined actually corresponds to the name given as the first argument of the macro.
(0062666)
abv (manager)
2017-01-17 07:10

Reviewed with corrections, please test. First, please check compilation on all supported compilers.
(0062686)
BenjaminBihler (developer)
2017-01-17 10:49

Well done, works nicely here. :-)
(0062754)
apv (tester)
2017-01-18 15:04

Dear BugMaster,

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

Number of compiler warnings:
occt component:
   Linux: 0 (0 on master)
   Windows: 0 (0 on master)
   MasOS: 0 (0 on master)
products component:
   Linux: 63
   Windows: 0
   MacOS: 1146

Compilation error has been detected during building of Qt-based OCCT samples on Linux:
http://jenkins-test-07.nnov.opencascade.com/view/CR28355_2-master/job/CR28355_2-master-OCCT-Debian70-64-qt-samples-linux/1/parsed_console/ [^]

Regressions/Differences:
Not detected

Testing cases:
Not needed

Testing on Linux:
Total MEMORY difference: 93556163 / 92911266 [+0.69%]
Total CPU difference: 21356.60000000021 / 21506.1200000003 [-0.70%]

Testing on Windows:
Total MEMORY difference: 58650792 / 58649007 [+0.00%]
Total CPU difference: 19417.444469998558 / 19749.742200098677 [-1.68%]
(0062755)
apv (tester)
2017-01-18 15:05

Dear Andrey,

Branch CR28355_2 has been rejected due to:
- compilation errors
(0062756)
git (administrator)
2017-01-18 15:19

Branch CR28355_2 has been updated by abv.

SHA-1: 88dd284fd5d879d3bc6f227826ae0acad8cae7b0


Detailed log of new commits:

Author: abv
Date: Wed Jan 18 15:19:05 2017 +0300

    RTTI definition is corrected in samples/qt/FuncDemo/src/CircleDriver.h

(0062757)
abv (manager)
2017-01-18 15:22

Qt sample is corrected, please check its building (only)
(0062771)
apn (administrator)
2017-01-18 18:17

Debian60-64 gcc 4.4.5
http://jenkins-test-08.nnov.opencascade.com/view/CR28355_2/view/OCCT%20compile/job/CR28355_2_master-OCCT-Debian60-64-opt-compile/1/parsed_console/ [^]

CentOS64-64 gcc 4.4.7
http://jenkins-test-08.nnov.opencascade.com/view/CR28355_2/view/OCCT%20compile/job/CR28355_2_master-OCCT-CentOS64-64-opt-compile/1/parsed_console/ [^]
(0062772)
git (administrator)
2017-01-18 18:34

Branch CR28355_2 has been updated by abv.

SHA-1: 0f60364a408c2be1f5a7d2ccaff216564fb29e5f


Detailed log of new commits:

Author: abv
Date: Wed Jan 18 18:34:43 2017 +0300

    // use std::tr2::diract_bases only for GCC 4.7+

(0062773)
abv (manager)
2017-01-18 18:36

I have corrected version of GCC (std::tr2 namespaces seems to be available only since GCC 4.7, at least it is not present in documentation on GCC 4.6.4, see https://gcc.gnu.org/onlinedocs/gcc-4.6.4/libstdc++/api/namespaces.html [^]).
Please check compilation again.
(0062774)
apn (administrator)
2017-01-18 19:18

The same platforms:
http://jenkins-test-08.nnov.opencascade.com/view/CR28355_2/view/OCCT%20compile/job/CR28355_2_master-OCCT-CentOS64-64-opt-compile/2/parsed_console/ [^]
http://jenkins-test-08.nnov.opencascade.com/view/CR28355_2/view/OCCT%20compile/job/CR28355_2_master-OCCT-Debian60-64-opt-compile/2/parsed_console/ [^]

/OCCT/src/SelectMgr/SelectMgr_TriangularFrustum.hxx:95: error: invalid use of template-name 'SelectMgr_Frustum' without an argument list
/OCCT/src/SelectMgr/SelectMgr_TriangularFrustum.hxx:95: error: type/value mismatch at argument 1 in template parameter list for 'template<class T1, class T2, class Dummy> struct opencascade::is_base_but_not_same'
/OCCT/src/SelectMgr/SelectMgr_TriangularFrustum.hxx:95: error: expected a type, got 'SelectMgr_Frustum'
(0062775)
git (administrator)
2017-01-18 21:27

Branch CR28355_2 has been updated by abv.

SHA-1: 0b035e58f38884177b4ffd0892a4df8dc87320cd


Detailed log of new commits:

Author: abv
Date: Wed Jan 18 21:26:48 2017 +0300

    // minor correction for GCC 4.4

(0062776)
abv (manager)
2017-01-19 00:02

I have pushed the change which I hope will fix the issue. Alas, I cannot check with GCC older than 4.7 (Ubuntu seems not supporting it), but it builds OK with GCC 5.1, CLang 3.6, VS 2010 and 2015. Please re-try.
(0062779)
apv (tester)
2017-01-19 10:16

Dear BugMaster,

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

Number of compiler warnings:
occt component:
   Linux: 0 (0 on master)
   Windows: 0 (0 on master)
   MasOS: 0 (0 on master)
products component:
   Linux: 63
   Windows: 0
   MacOS: 1160

Compilation error has been detected during building of Qt-based OCCT samples on Linux:
http://jenkins-test-07.nnov.opencascade.com/view/CR28355_2-master/job/CR28355_2-master-OCCT-Debian70-64-qt-samples-linux/3/parsed_console/ [^]
(0062780)
apv (tester)
2017-01-19 10:17

Dear Andrey,

Branch CR28355_2 has been rejected due to:
- compilation errors
(0062782)
git (administrator)
2017-01-19 11:38

Branch CR28355_2 has been updated by abv.

SHA-1: dc57932ed20908eea0d8ce91e83eeb6b79c47d46


Detailed log of new commits:

Author: abv
Date: Thu Jan 19 11:38:01 2017 +0300

    // RTTI definitions are corrected in Qt sample FuncDemo

(0062783)
abv (manager)
2017-01-19 11:38

Sample building should be corrected now, please check
(0063612)
git (administrator)
2017-02-08 11:36

Branch CR28355 has been deleted by kgv.

SHA-1: 08b3a7f398238b29f11fa557b8babfc24efb96c3
(0063613)
git (administrator)
2017-02-08 11:36

Branch CR28355_2 has been deleted by kgv.

SHA-1: dc57932ed20908eea0d8ce91e83eeb6b79c47d46

- Related Changesets
occt: master 0e9fe060
Timestamp: 2017-01-19 13:48:08
Author: BenjaminBihler
Committer: apn
Details ] Diff ]
0028355: Stating wrong parent class in DEFINE_STANDARD_RTTIEXT is not recognized during compilation

Added compile-time checks (static_assert) in DEFINE_STANDARD_RTTI*(A,B) macros to check that A is actually the class being defined, and B is its base class.
For GCC compiler version 4.7 and later on, check ensures that B is direct base class of A.

Fixed dubious RTTI definitions.
mod - samples/qt/FuncDemo/src/CircleDriver.h Diff ] File ]
mod - samples/qt/FuncDemo/src/ConeDriver.h Diff ] File ]
mod - samples/qt/FuncDemo/src/CylinderDriver.h Diff ] File ]
mod - samples/qt/FuncDemo/src/PointDriver.h Diff ] File ]
mod - samples/qt/FuncDemo/src/PrismDriver.h Diff ] File ]
mod - samples/qt/FuncDemo/src/ShapeSaverDriver.h Diff ] File ]
mod - src/AIS/AIS_AnimationTimer.hxx Diff ] File ]
mod - src/SelectMgr/SelectMgr_TriangularFrustum.hxx Diff ] File ]
mod - src/Standard/Standard_Type.hxx Diff ] File ]
mod - src/StepVisual/StepVisual_CharacterizedObjectAndCharacterizedRepresentationAndDraughtingModelAndRepresentation.hxx Diff ] File ]
mod - src/ViewerTest/ViewerTest_ObjectCommands.cxx Diff ] File ]

- Issue History
Date Modified Username Field Change
2017-01-13 18:34 BenjaminBihler New Issue
2017-01-13 18:34 BenjaminBihler Assigned To => BenjaminBihler
2017-01-13 19:40 git Note Added: 0062596
2017-01-13 19:41 BenjaminBihler Assigned To BenjaminBihler => abv
2017-01-13 19:41 BenjaminBihler Status new => resolved
2017-01-13 19:41 BenjaminBihler Steps to Reproduce Updated View Revisions
2017-01-16 11:45 git Note Added: 0062618
2017-01-16 11:49 git Note Added: 0062620
2017-01-16 13:48 git Note Added: 0062624
2017-01-16 13:51 abv Relationship added has duplicate 0028184
2017-01-16 13:54 BenjaminBihler Note Added: 0062625
2017-01-16 14:41 abv Note Added: 0062630
2017-01-16 14:41 abv Note Edited: 0062630 View Revisions
2017-01-16 16:20 BenjaminBihler Note Added: 0062635
2017-01-16 16:21 git Note Added: 0062636
2017-01-16 18:28 abv Note Added: 0062650
2017-01-16 18:38 BenjaminBihler Note Added: 0062652
2017-01-16 20:43 git Note Added: 0062659
2017-01-16 22:41 git Note Added: 0062664
2017-01-17 07:09 abv Note Added: 0062665
2017-01-17 07:10 abv Note Added: 0062666
2017-01-17 07:10 abv Assigned To abv => bugmaster
2017-01-17 07:10 abv Status resolved => reviewed
2017-01-17 10:49 BenjaminBihler Note Added: 0062686
2017-01-17 17:19 apv Test case number => Not needed
2017-01-17 17:32 apv Assigned To bugmaster => apv
2017-01-18 15:04 apv Note Added: 0062754
2017-01-18 15:04 apv Assigned To apv => abv
2017-01-18 15:04 apv Status reviewed => assigned
2017-01-18 15:05 apv Note Added: 0062755
2017-01-18 15:19 git Note Added: 0062756
2017-01-18 15:22 abv Status assigned => resolved
2017-01-18 15:22 abv Note Added: 0062757
2017-01-18 15:22 abv Assigned To abv => apv
2017-01-18 15:22 abv Status resolved => reviewed
2017-01-18 18:17 apn Note Added: 0062771
2017-01-18 18:19 apn Assigned To apv => abv
2017-01-18 18:19 apn Status reviewed => feedback
2017-01-18 18:34 git Note Added: 0062772
2017-01-18 18:36 abv Note Added: 0062773
2017-01-18 18:42 abv Assigned To abv => apn
2017-01-18 19:18 apn Note Added: 0062774
2017-01-18 19:18 apn Assigned To apn => abv
2017-01-18 21:27 git Note Added: 0062775
2017-01-19 00:02 abv Note Added: 0062776
2017-01-19 00:02 abv Assigned To abv => apn
2017-01-19 10:16 apv Note Added: 0062779
2017-01-19 10:17 apv Note Added: 0062780
2017-01-19 11:38 git Note Added: 0062782
2017-01-19 11:38 abv Note Added: 0062783
2017-01-19 17:29 apn Assigned To apn => bugmaster
2017-01-19 17:29 apn Status feedback => tested
2017-01-20 16:12 apn Changeset attached => occt master 0e9fe060
2017-01-20 16:12 apn Assigned To bugmaster => apn
2017-01-20 16:12 apn Status tested => verified
2017-01-20 16:12 apn Resolution open => fixed
2017-02-08 11:36 git Note Added: 0063612
2017-02-08 11:36 git Note Added: 0063613
2017-09-29 16:21 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