AutosarC++17_03-A2.8.4

C-style comments shall not be used

Required inputs: IR

Rationale

C-style comment delimiters /* ... */are not supposed to be used as they make the source code less readable and introduce errors when nesting a C-style comment in the C-style comment.

Example
// $Id: A2-8-4.cpp 271687 2017-03-23 08:57:35Z piotr.tanski $
#include <cstdint>
void fn(bool b1, bool b2) noexcept {
// Introduces x of type std::int16_t // Compliant
std::int32_t x = 0;
// std::int16_t x = 0; // commented out temporarily, type too small        //
// Compliant
if (b1) {
if (b2) {
/*
* Do something special here   // Non-compliant
*/
}
}

//   /* disable this code temporarily
//   if (b1)
//   {
//     /* TODO: should we do something? */   // Non-compliant - compilation
//   error
//   }
//   */
}
See Also
  • MISRA C++ 2008 [6]: 2-7-1 The character sequence /* shall not be used within a C-style comment.
  • HIC++ v4.0 [8]: 2.3.1 Do not use the C comment delimiters /* ... */.

Possible Messages

Key

Text

Severity

Disabled

cpp_comment_style

Use of invalid comment style in C++ unit.

None

False

Options

exception

exception : str | None = None

Start of a valid comment, even if it has an invalid prefix.
 

invalid

invalid : str = '/*'

Start of an invalid comment.