Versions Compared

Key

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

...

All occurrences in a source file of the following sequences of three characters (that is, trigraph sequences) are replaced with the corresponding single character.

??=

#

 

??)

]

 

??!

|

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="815fd5a5abb5e623-120ef15b-4d7f4077-aa348bb2-5543781075e6955137e46d75"><ac:plain-text-body><![CDATA[

??(

[

 

??'

^

 

??>

}

]]></ac:plain-text-body></ac:structured-macro>

??/

\

 

??<

{

 

??-

~

...

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
lang#ffccccc
// what 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
langcccccff
// what 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#ffcccc
size_t i = /* some initial value */;
if (i > 9000) {
   if (puts("Over 9000!??!") == EOF) {
     /* Handle Error */
   }
}

...

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
langccccffc
size_t i = /* some initial value */;
/* assignment of i */
if (i > 9000) {
   if (puts("Over 9000!?""?!") == EOF) {
     /* Handle Error */
   }
}

...