![]() |
A3-3-2 Contradictory examples? - Printable Version +- MISRA Discussion Forums (https://forum.misra.org.uk) +-- Forum: MISRA C++ (https://forum.misra.org.uk/forumdisplay.php?fid=18) +--- Forum: AUTOSAR C++:2014 rules (https://forum.misra.org.uk/forumdisplay.php?fid=185) +--- Thread: A3-3-2 Contradictory examples? (/showthread.php?tid=1731) |
A3-3-2 Contradictory examples? - cgpzs - 17-03-2025 In Rule A3-3-2, there's an example with "class A" which has a non-constexpr, user-defined constructor. On line 31, we have a compliant example: Code: A instance{}; // Compliant - constant (value) initialization However, on line 37 it's no longer compliant: Code: static A a{}; // Non-compliant - A’s default c’tor is not constexpr There seems to be a contradiction here. Either the code is doing value initialization, or it's calling a constructor, but not both. Which one is it? In other words, it seems like both examples are doing the same thing, so both should either be compliant or non-compliant. Would you agree? RE: A3-3-2 Contradictory examples? - misra cpp - 28-03-2025 This appears to be an error, thanks for pointing it out. Line 31 should be non-compliant, for the same reason as line 37 RE: A3-3-2 Contradictory examples? - cgpzs - 31-03-2025 (28-03-2025, 01:49 PM)misra cpp Wrote: This appears to be an error, thanks for pointing it out. I agree, thanks for the clarification! |