![]() |
|
Clarification Rule 0.2.1 - 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.0 Language independent issues (https://forum.misra.org.uk/forumdisplay.php?fid=189) +---- Thread: Clarification Rule 0.2.1 (/showthread.php?tid=1779) |
Clarification Rule 0.2.1 - hahn - 27-08-2026 Hi, I have a question regarding rule 0.2.1 on the following code: Code: namespace {Case (1) is clearly compliant as b has class type Base and Base has a user-provided constructor. Case (2) is unclear, as the default constructor of Derived is not user-provided, if I understand the C++ standard correctly, as the user does not declare it at all. Still case (2) seems fine and in line with the rule's rationale. It would be great to get a clarification whether case (2) is considered compliant or not, and if compliant, what the intended definition of "use" should be. Thanks a lot! RE: Clarification Rule 0.2.1 - misra cpp - 28-08-2026 You're right, the intent of 0.2.1 was that 'd' in you example should be compliant, but a strict reading of the rule says its not. The problem is the last paragraph in the rule: "The variable is of class type and has a user-provided constructor or a user-provided destructor.". The two occurrences of 'user-provided' should be 'non-trivial'. This has been noted for future revision. In the short term, you can either deviate or provide an explicit constructor for Devired. |