Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

In this noncompliant code example, a++ is not executed because the trigraph sequence ??/ is replaced by \, logically putting a++ on the same line as the comment.:

Code Block
bgColor#FFcccc
langc
// whatWhat is the value of a now??/
a++;

...

The following compliant solution eliminates the accidental introduction of the trigraph by separating the question marks.:

Code Block
bgColor#ccccFF
langc
// whatWhat is the value of a now? ?/
a++;

...

This noncompliant code example includes the trigraph sequence ??!, which is replaced by the character |.:

Code Block
bgColor#FFcccc
langc
size_t i = /* some initial value */;
if (i > 9000) {
   if (puts("Over 9000!??!") == EOF) {
     /* Handle Errorerror */
   }
}

This example prints Over 9000!| if a C-compliant compiler is used.

...

This compliant solution uses string concatenation to concatenate the two question marks; otherwise, they are interpreted as beginning a trigraph sequence.:

Code Block
bgColor#ccccFF
langc
size_t i = /* some initial value */;
/* assignment of i */
if (i > 9000) {
   if (puts("Over 9000!?""?!") == EOF) {
     /* Handle Errorerror */
   }
}

This code prints Over 9000!??!, as intended.

...

ToolVersionCheckerDescription

ECLAIR

Include Page
ECLAIR_V
ECLAIR_V

dtrigraf

Fully implemented.
GCC
Include Page
GCC_V
GCC_V
 

Can detect violation of this recommendation when the -Wtrigraphs flag is used.

LDRA tool suite

Include Page
LDRA_V
LDRA_V

81 S

Fully implemented.
PRQA QA-C
Include Page
PRQA_V
PRQA_V
3601Partially implemented

...

Bibliography

[ISO/IEC 9899:2011]Section 5.2.1.1, "Trigraph Sequences"

...