MISRA Discussion Forums
15.1.4 potentially incomplete wording - 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: 15.1.4 potentially incomplete wording (/showthread.php?tid=1762)



15.1.4 potentially incomplete wording - hahn - 16-01-2026

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!


RE: 15.1.4 potentially incomplete wording - misra cpp - 23-01-2026

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"