![]() |
|
Rule 15.1.2 - Printable Version +- MISRA Discussion Forums (https://forum.misra.org.uk) +-- Forum: MISRA C++ (https://forum.misra.org.uk/forumdisplay.php?fid=18) +--- Forum: MISRA C++:2023 guidelines (https://forum.misra.org.uk/forumdisplay.php?fid=188) +---- Forum: 4.15 Special member functions (https://forum.misra.org.uk/forumdisplay.php?fid=201) +---- Thread: Rule 15.1.2 (/showthread.php?tid=1764) |
Rule 15.1.2 - Merge - 19-02-2026 Hi, We are having a discussion internally about how to interpret rule 15.1.2. In particular, the rule exception says that a class is considered empty "when it has [...], no virtual member functions, [...]". The question is whether a virtual (defaulted) destructor is considered a virtual member function in this context. For example, whether the following class is considered empty or not for the sake of this rule: Code: struct Base () {My personal interpretation is that this class is not considered empty (it will contain the v-table), so it does not qualify as an exception w.r.t. rule 15.2 when used as a base class. Can you confirm that this interpretation is correct? Thank you very much and best regards, Daniel "Merge" Merget RE: Rule 15.1.2 - misra cpp - 20-02-2026 Yes, we agree with your conclusion: Base is not empty, so would have to be explicitly initialised in any derived classes. We know in this case that's rather redundant, but a small price for a simpler rule. |