View Issue Details

IDProjectCategoryView StatusLast Update
0028355CommunityOCCT:Foundation Classespublic2017-09-29 16:24
ReporterBenjaminBihler Assigned Toapn  
PrioritynormalSeverityminor 
Status closedResolutionfixed 
PlatformLinuxOSDebian 6.0 
Product Version7.1.0 
Target Version7.2.0Fixed in Version7.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

Activities

git

2017-01-13 19:40

administrator   ~0062596

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.

git

2017-01-16 11:45

administrator   ~0062618

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).

git

2017-01-16 11:49

administrator   ~0062620

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.

git

2017-01-16 13:48

administrator   ~0062624

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.

BenjaminBihler

2017-01-16 13:54

developer   ~0062625

The duplicate is invisible for me. :-(

abv

2017-01-16 14:41

manager   ~0062630

Last edited: 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.

BenjaminBihler

2017-01-16 16:20

developer   ~0062635

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.

git

2017-01-16 16:21

administrator   ~0062636

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++.

abv

2017-01-16 18:28

manager   ~0062650

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.

BenjaminBihler

2017-01-16 18:38

developer   ~0062652

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.)

git

2017-01-16 20:43

administrator   ~0062659

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

git

2017-01-16 22:41

administrator   ~0062664

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.

abv

2017-01-17 07:09

manager   ~0062665

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.

abv

2017-01-17 07:10

manager   ~0062666

Reviewed with corrections, please test. First, please check compilation on all supported compilers.

BenjaminBihler

2017-01-17 10:49

developer   ~0062686

Well done, works nicely here. :-)

apv

2017-01-18 15:04

tester   ~0062754

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%]

apv

2017-01-18 15:05

tester   ~0062755

Dear Andrey,

Branch CR28355_2 has been rejected due to:
- compilation errors

git

2017-01-18 15:19

administrator   ~0062756

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

abv

2017-01-18 15:22

manager   ~0062757

Qt sample is corrected, please check its building (only)

apn

2017-01-18 18:17

administrator   ~0062771

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/

git

2017-01-18 18:34

administrator   ~0062772

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+

abv

2017-01-18 18:36

manager   ~0062773

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.

apn

2017-01-18 19:18

administrator   ~0062774

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'

git

2017-01-18 21:27

administrator   ~0062775

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

abv

2017-01-19 00:02

manager   ~0062776

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.

apv

2017-01-19 10:16

tester   ~0062779

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/

apv

2017-01-19 10:17

tester   ~0062780

Dear Andrey,

Branch CR28355_2 has been rejected due to:
- compilation errors

git

2017-01-19 11:38

administrator   ~0062782

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

abv

2017-01-19 11:38

manager   ~0062783

Sample building should be corrected now, please check

git

2017-02-08 11:36

administrator   ~0063612

Branch CR28355 has been deleted by kgv.

SHA-1: 08b3a7f398238b29f11fa557b8babfc24efb96c3

git

2017-02-08 11:36

administrator   ~0063613

Branch CR28355_2 has been deleted by kgv.

SHA-1: dc57932ed20908eea0d8ce91e83eeb6b79c47d46

Related Changesets

occt: master 0e9fe060

2017-01-19 13:48:08

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.
Affected Issues
0028355
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
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:54 BenjaminBihler Note Added: 0062625
2017-01-16 14:41 abv Note Added: 0062630
2017-01-16 14:41 abv Note Edited: 0062630
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 aiv Fixed in Version => 7.2.0
2017-09-29 16:24 aiv Status verified => closed