View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0028355 | Community | OCCT:Foundation Classes | public | 2017-01-13 18:34 | 2017-09-29 16:24 |
Reporter | BenjaminBihler | Assigned To | apn | ||
Priority | normal | Severity | minor | ||
Status | closed | Resolution | fixed | ||
Platform | Linux | OS | Debian 6.0 | ||
Product Version | 7.1.0 | ||||
Target Version | 7.2.0 | Fixed in Version | 7.2.0 | ||
Summary | 0028355: Stating wrong parent class in DEFINE_STANDARD_RTTIEXT is not recognized during compilation | ||||
Description | It 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 Reproduce | Not required | ||||
Tags | No tags attached. | ||||
Test case number | Not needed | ||||
|
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. |
|
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). |
|
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. |
|
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. |
|
The duplicate is invisible for me. :-( |
|
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. |
|
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. |
|
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++. |
|
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. |
|
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.) |
|
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 |
|
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. |
|
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. |
|
Reviewed with corrections, please test. First, please check compilation on all supported compilers. |
|
Well done, works nicely here. :-) |
|
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%] |
|
Dear Andrey, Branch CR28355_2 has been rejected due to: - compilation errors |
|
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 |
|
Qt sample is corrected, please check its building (only) |
|
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/ |
|
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+ |
|
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. |
|
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' |
|
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 |
|
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. |
|
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/ |
|
Dear Andrey, Branch CR28355_2 has been rejected due to: - compilation errors |
|
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 |
|
Sample building should be corrected now, please check |
|
Branch CR28355 has been deleted by kgv. SHA-1: 08b3a7f398238b29f11fa557b8babfc24efb96c3 |
|
Branch CR28355_2 has been deleted by kgv. SHA-1: dc57932ed20908eea0d8ce91e83eeb6b79c47d46 |
occt: master 0e9fe060 2017-01-19 13:48:08 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 |
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 |
|
Note Added: 0062630 | |
2017-01-16 14:41 |
|
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 |
|
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 |
|
Note Added: 0062665 | |
2017-01-17 07:10 |
|
Note Added: 0062666 | |
2017-01-17 07:10 |
|
Assigned To | abv => bugmaster |
2017-01-17 07:10 |
|
Status | resolved => reviewed |
2017-01-17 10:49 | BenjaminBihler | Note Added: 0062686 | |
2017-01-17 17:19 |
|
Test case number | => Not needed |
2017-01-17 17:32 |
|
Assigned To | bugmaster => apv |
2017-01-18 15:04 |
|
Note Added: 0062754 | |
2017-01-18 15:04 |
|
Assigned To | apv => abv |
2017-01-18 15:04 |
|
Status | reviewed => assigned |
2017-01-18 15:05 |
|
Note Added: 0062755 | |
2017-01-18 15:19 | git | Note Added: 0062756 | |
2017-01-18 15:22 |
|
Status | assigned => resolved |
2017-01-18 15:22 |
|
Note Added: 0062757 | |
2017-01-18 15:22 |
|
Assigned To | abv => apv |
2017-01-18 15:22 |
|
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 |
|
Note Added: 0062773 | |
2017-01-18 18:42 |
|
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 |
|
Note Added: 0062776 | |
2017-01-19 00:02 |
|
Assigned To | abv => apn |
2017-01-19 10:16 |
|
Note Added: 0062779 | |
2017-01-19 10:17 |
|
Note Added: 0062780 | |
2017-01-19 11:38 | git | Note Added: 0062782 | |
2017-01-19 11:38 |
|
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 |
|
Fixed in Version | => 7.2.0 |
2017-09-29 16:24 |
|
Status | verified => closed |