AutosarC++17_10-A2.5.1

Trigraphs shall not be used

Required inputs: IR

Rationale

Trigraphs are denoted to be a sequence of 2 question marks followed by a specified third character (e.g. ??’ represents a ~character. They can cause accidental confusion with other uses of two question marks.

The Trigraphs are: ??=, ??/, ??’, ??(, ??), ??!, ??<, ??>, ??-.

Example
//% $Id: A2-5-1.cpp 289436 2017-10-04 10:45:23Z michal.szczepankiewicz $
#include <iostream>
void Fn1() {
  std::cout << "Enter date ??/??/??"; // Non-compliant, ??/??/?? becomes \\??
                                      // after trigraph translation
}
void Fn2() {
  std::cout << "Enter date dd/mm/yy"; // Compliant
}
See Also
  • MISRA C++2008: Rule 2-3-1 (Required) Trigraphs shall not be used.
  • JSF December 2005 [7]: AV Rule 11 Trigraphs will not be used.
  • HIC++ v4.0 [8]: 2.2.1 Do not use digraphs or trigraphs.

Possible Messages

Key

Text

Severity

Disabled

trigraph_use

Use of trigraph.

None

False

Options

allow_in_comments

allow_in_comments : bool = True

Allow the use of trigraphs in comments.

Exception: a trigraph at the end of a line that might be interpreted as a line continuation is not allowed even if this option is enabled.