AutosarC++19_03-A2.7.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-7-1.cpp 305382 2018-01-26 06:32:15Z 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