AutosarC++17_03-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 271687 2017-03-23 08:57:35Z piotr.tanski $
#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