MISRA.TOKEN.BADCOMInappropriate character sequence in a comment.
MISRA 2012 C Rule 3.1: The character sequences /* and // shall not be used within a commentCategory: Required Analysis: Decidable, Single Translation Unit Applies to: C90, C99 RationaleIf a comment starting sequence, /* or //, occurs within a /* comment, is it quite likely to be caused by a missing */ comment ending sequence. If a comment starting sequence occurs within a // comment, it is probably because a region of code has been commented-out using //. ExceptionThe sequence // is permitted within a // comment. ExampleConsider the following code fragment: /* some comment, end comment marker accidentally omitted <<New Page>> Perform_Critical_Safety_Function( X ); /* this comment is non-compliant */ In reviewing the page containing the call to the function, the assumption is that it is executed code. Because of the accidental omission of the end comment marker, the call to the safety critical function will not be executed. In the following C99 example, the presence of // comments changes the meaning of the program:
x = y // /* + z // */ ; This gives x = y + z; but would have been x = y; in the absence of the two // comment start sequences. See alsoDir 4.4 MISRA-C 2004 Rule 2.3 (required): The character sequence /* shall not be used within a comment.Inappropriate character sequence in a comment. C does not support the nesting of comments even though some compilers support this as a language extension. A comment begins with /* and continues until the first */ is encountered. Any /* occurring inside a comment is a violation of this rule. ExampleConsider the following code fragment: /* some comment, end comment marker accidentally omitted <<New Page>> Perform_Critical_Safety_Function(X); /* this comment is not compliant */ In reviewing the page containing the call to the function, the assumption is that it is executed code. Because of the accidental omission of the end comment marker, the call to the safety critical function will not be executed. MISRA-C++ 2008 Rule 2-7-1 (required): The character sequence '/*' shall not be used within a C-style comment.RationaleC++ does not support the nesting of C-style comments even though some compilers support this as a non-portable language extension. A comment beginning with '/*' continues until the first '*/' is encountered. Any '/*' occurring inside a comment is a violation of this rule. ExampleConsider the following code fragment: /* some comment, end comment marker accidentally omitted Perform_Critical_Safety_Function(X); /* this "comment" is Non-compliant */ In reviewing the code containing the call to the function, the assumption is that it is executed code. Because of the accidental omission of the end comment marker, the call to 'Perform_Critical_Safety_Function' will not be executed. |