AutosarC++17_10-A2.8.1ΒΆ

The character shall not occur as a last character of a C++ comment

Required inputs: IR

Rationale

If the last character in a single-line C++ comment is \, then the comment will continue in the next line. This may lead to sections of code that are unexpectedly commented out.

Example
// $Id: A2-8-1.cpp 289436 2017-10-04 10:45:23Z michal.szczepankiewicz $
#include <cstdint>
void Fn() noexcept {
  std::int8_t idx = 0;
  // Incrementing idx before the loop starts // Requirement X.X.X \\
       ++idx; // Non-compliant - ++idx was unexpectedly commented-out because of character occurrence in the end of C++ comment

  constexpr std::int8_t limit = 10;
  for (; idx <= limit; ++idx) {
    // ...
  }
}
See Also
  • none

Possible Messages

Key

Text

Severity

Disabled

line_splicing_in_cpp_comment

Line-splicing shall not be used in // comments.

None

False

Options