Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
What is the intention of A15-4-4
#1
Hi experts,

A15-4-4 

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

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


provides this example (17-10):
Code:
// ...
Code:
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. 
Code:
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 = []() { return 42; })?
5. (Bonus question) will a similar check be added to the next version of MISRA C++?
Reply
#2
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
Posted by and on behalf of
the MISRA C++ Working Group
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)