Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Rule 15.1.2
#1
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 () {
    virtual ~Base() = default;
};

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 b
est regards,
Daniel "Merge" Merget
Reply
#2
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.
Posted by and on behalf of
the MISRA C++ Working Group
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)