MISRA Discussion Forums
What is the intention of A15-4-4 - Printable Version

+- MISRA Discussion Forums (https://forum.misra.org.uk)
+-- Forum: MISRA C++ (https://forum.misra.org.uk/forum-18.html)
+--- Forum: AUTOSAR C++:2014 rules (https://forum.misra.org.uk/forum-185.html)
+--- Thread: What is the intention of A15-4-4 (/thread-1624.html)

What is the intention of A15-4-4 - kth - 23-06-2022

Hi experts,


Quote:Rule A15-4-4 (required, implementation, automated)

A declaration of non-throwing function shall contain noexcept specification.

provides this example (17-10):
// ...
void F1(); // Compliant - f1, without noexcept specification, declares to throw
// exceptions implicitly

// ...

The implementation of F1 is not provided.

I would assume that a matching implementation of  F1() would be, e.g. 
void F1() {
  // something ...
  throw std::runtime_error{"problem"};

My questions:
1. Is my implementation of F1 above correct?
2. What should a compliant static analysis tool report, when F1 does not throw?
3. Shall a compliant AUTOSAR C++ checker tool here report a violation (error/warning/...) or is this kind of a hint or note? 
4. What shall be reported for the operator()() of a lambda that does not throw and does not explicitly add noexcept (example: auto l = [font=Consolas, "Liberation Mono", Courier, monospace, Consolas, "Courier New", monospace][]() { return 42; }[/font])?
5. (Bonus question) will a similar check be added to the next version of MISRA C++?

RE: What is the intention of A15-4-4 - misra cpp - 24-06-2022

1: It would be a valid implementation that makes F1 compliant
2: If a function cannot throw but is not marked as noexcept, it should be reported as a violation
3: Autosar does not define how a tool should report a violation
4: Lambdas are treated the same as other functions, so the example should be marked noexcept
5: Its under discussion, but currently we have no plans to include a similar rule