View Issue Details

IDProjectCategoryView StatusLast Update
0025725Open CASCADEOCCT:Codingpublic2023-08-01 15:09
ReporteraznAssigned Toabv 
PrioritynormalSeverityminor 
Status newResolutionopen 
Target VersionUnscheduled 
Summary0025725: Avoid invocation of virtual methods in constructors and destructors
DescriptionStatic 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.
TagsNo tags attached.
Test case number

Attached Files

  • scan-build-OCE.txt (24,250 bytes)

Relationships

related to 0025622 closedbugmaster Open CASCADE CAST analysis: Avoid invocation of virtual Methods of the declared Class in a Constructor or Destructor 
related to 0025572 closedbugmaster Open CASCADE Remove MMgt_TShared class. 
parent of 0027067 closedabv Open CASCADE Avoid use of virtual methods for implementation of destructors in legacy classes 

Activities

barbier

2015-01-20 14:35

updater   ~0036263

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.

barbier

2015-01-20 14:35

updater  

scan-build-OCE.txt (24,250 bytes)

abv

2018-02-25 23:06

manager   ~0074129

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

Issue History

Date Modified Username Field Change
2015-01-20 11:53 azn New Issue
2015-01-20 11:53 azn Assigned To => azn
2015-01-20 11:54 azn Description Updated
2015-01-20 11:54 azn Relationship added related to 0025622
2015-01-20 11:55 azn Relationship added related to 0025572
2015-01-20 11:56 azn Assigned To azn => abv
2015-01-20 14:35 barbier Note Added: 0036263
2015-01-20 14:35 barbier File Added: scan-build-OCE.txt
2015-03-27 21:32 abv Target Version 6.9.0 => 7.0.0
2015-12-14 22:44 abv Target Version 7.0.0 => 7.1.0
2016-01-08 19:55 abv Relationship added parent of 0027067
2016-01-08 19:59 abv Summary Avoid 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:59 abv Description Updated
2016-11-03 17:13 abv Target Version 7.1.0 => 7.2.0
2017-07-20 12:29 kgv Target Version 7.2.0 => 7.3.0
2018-02-25 21:04 abv Target Version 7.3.0 => 7.4.0
2018-02-25 23:06 abv Note Added: 0074129
2018-02-25 23:07 abv Note Edited: 0074129
2019-07-10 19:27 abv Target Version 7.4.0 => 7.5.0
2020-09-11 15:34 utverdov Target Version 7.5.0 => 7.6.0
2021-09-20 10:09 kgv Target Version 7.6.0 => 7.7.0
2022-08-17 12:01 kgv Target Version 7.7.0 => 7.8.0
2023-08-01 15:09 dpasukhi Target Version 7.8.0 => Unscheduled