Cppcheck produces neither a zerodiv nor a zerodivcond diagnostic. The checker report lists CheckOther::checkZeroDivision as active.
Expected behavior
Cppcheck should report zerodiv at line 9. Constructing MostDerived invokes Base(), which sets the virtual base member value to zero before the Derived member initializer divides by it.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi, I found a false negative in Cppcheck 2.21.0 when the most-derived class default-initializes a virtual base member to zero.
Affected checker
Cppcheck zerodivMinimal reproducer
Reproduction command
Current behavior
Cppcheck produces neither a
zerodivnor azerodivconddiagnostic. The checker report listsCheckOther::checkZeroDivisionas active.Expected behavior
Cppcheck should report
zerodivat line 9. ConstructingMostDerivedinvokesBase(), which sets the virtual base membervalueto zero before theDerivedmember initializer divides by it.See https://trac.cppcheck.net/ticket/1025, https://trac.cppcheck.net/ticket/6294