MantisBT - Open CASCADE
View Issue Details
0025725Open CASCADE[OCCT] OCCT:Codingpublic2015-01-20 11:532020-09-11 15:34
[OCCT] 7.6.0* 
0025725: Avoid invocation of virtual methods in constructors and destructors
Static code analyzers complain about multiple places where virtual method is called from constructor or destructor, which may result in behavior different from expected (own method will be called in all cases).

More information: CAST report issue №628.
No tags attached.
related to 0025622closed bugmaster Open CASCADE CAST analysis: Avoid invocation of virtual Methods of the declared Class in a Constructor or Destructor 
related to 0025572closed bugmaster Open CASCADE Remove MMgt_TShared class. 
parent of 0027067closed abv Open CASCADE Avoid use of virtual methods for implementation of destructors in legacy classes 
txt scan-build-OCE.txt (24,250) 2015-01-20 14:35
Issue History
2015-01-20 11:53aznNew Issue
2015-01-20 11:53aznAssigned To => azn
2015-01-20 11:54aznDescription Updatedbug_revision_view_page.php?rev_id=9103#r9103
2015-01-20 11:54aznRelationship addedrelated to 0025622
2015-01-20 11:55aznRelationship addedrelated to 0025572
2015-01-20 11:56aznAssigned Toazn => abv
2015-01-20 14:35barbierNote Added: 0036263
2015-01-20 14:35barbierFile Added: scan-build-OCE.txt
2015-03-27 21:32abvTarget Version6.9.0 => 7.0.0
2015-12-14 22:44abvTarget Version7.0.0 => 7.1.0
2016-01-08 19:55abvRelationship addedparent of 0027067
2016-01-08 19:59abvSummaryAvoid invocation of virtual methods in a constructor and destructor of the Standard_Transient class inheritors. => Avoid invocation of virtual methods in constructors and destructors
2016-01-08 19:59abvDescription Updatedbug_revision_view_page.php?rev_id=12719#r12719
2016-11-03 17:13abvTarget Version7.1.0 => 7.2.0
2017-07-20 12:28kgvRelationship addedparent of 0028902
2017-07-20 12:29kgvTarget Version7.2.0 => 7.3.0
2018-02-25 21:04abvTarget Version7.3.0 => 7.4.0
2018-02-25 23:06abvNote Added: 0074129
2018-02-25 23:07abvNote Edited: 0074129bug_revision_view_page.php?bugnote_id=74129#r18656
2019-07-10 19:27abvTarget Version7.4.0 => 7.5.0
2020-09-11 15:34utverdovTarget Version7.5.0 => 7.6.0*

2015-01-20 14:35   
Scan-build reports similar issues, see attached file scan-build-OCE.txt (against OCE; it is not complete, I forgot to build DRAWEXE). It may be more complete than CAST report, since scan-build is able to also detect virtual functions indirectly called by constructors/destructors.
2018-02-25 23:06   
(edited on: 2018-02-25 23:07)
For the record, I tried to run scan-build for OCCT but it does not work for me (reports zero bugs). (Ubuntu 16.04 with CLang.)

According to documentation, scan-build works by replacing compiler by its own wrapper by tweaking CXX make veriable; however, scripts generated by CMake does not use such variable. Direct path to compiler is encoded instead. For instance, in build folder/src/TKQADraw/CMakeFiles/TKQADraw.dir/build.make:

src/TKQADraw/CMakeFiles/TKQADraw.dir/__/QABugs/QABugs.cxx.o: /home/abv/occt/src/QABugs/QABugs.cxx
    @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green --progress-dir=/home/abv/tmp/occt-clang/CMakeFiles --progress-num=$(CMAKE_PROGRESS_1) "Building CXX object src/TKQADraw/CMakeFiles/TKQADraw.dir/__/QABugs/QABugs.cxx.o"
    cd /home/abv/tmp/occt-clang/src/TKQADraw && /usr/bin/clang $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -o CMakeFiles/TKQADraw.dir/__/QABugs/QABugs.cxx.o -c /home/abv/occt/src/QABugs/QABugs.cxx