Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
15.1.4 potentially incomplete wording
#1
Hi,

For the following code, to the best of our knowledge, the C++ standard guarantees that m1 and m2 are both properly initialized when creating an object of type C ([class.base.init]p9 and [dcl.init]p7).

Code:
class M { M() {} };
class C {
  M m1;
  M m2[2];

  C() {}
};


However, being strict with the amplification given for rule 15.1.4, data member m2 cannot be considered initialized: neither is C() delegating, nor does m2 have a default member initializer, nor does it appear in the member initialization list, nor does its (array) type feature a constructor.
m1 is considered initialized as its type M has a constructor.

We think the code example should be compliant, but the rule amplification wording seems incomplete.
Can you confirm this interpretation or do we miss a reason for this code to be non-compliant w.r.t. 15.1.4?

Thanks in advance!
Reply
#2
You are correct, there is a missing bullet in the amplification 'A data member is initialized at the top of a constructor body if:'

We are considering adding: "The data member is an aggregate, and all the aggregate members are initialized"
Posted by and on behalf of
the MISRA C++ Working Group
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)