Versions Compared

Key

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

C99 supports The C standard supports universal character names that may be used in identifiers, character constants, and string literals to designate characters that are not in the basic character set. The universal character name \Unnnnnnnn designates the character whose eight-digit short identifier (as specified by ISO/IEC 10646) is nnnnnnnn. Similarly, the universal character name \unnnn designates the character whose four-digit short identifier is nnnn (and whose eight-digit short identifier is 0000nnnn).

C99C11, Section 5.1.1.2, Paragraph 4 para. 4 [ISO/IEC 9899:2011], says,

If a character sequence that matches the syntax of a universal character name is produced by token concatenation (6.10.3.3), the behavior is undefined.

...

Code Block
bgColor#FFCCCC
langc

#define assign(uc1, uc2, val) uc1##uc2 = val;

int \u0401;
assign( \u04, 01, 4);

...

GCC 4.3 on Linux refuses to compile this code; it complains of a "stray \," , referring to the universal character fragment in the invocation of the assign macro.

...

Code Block
bgColor#ccccff
langc

#define assign(ucn, val) ucn = val;

int \u0401;
assign( \u0401, 4);

...

section

Tool

Version

Checker

Description

LDRA tool suite

Include Page
LDRA_V
LDRA_V
section

573 S

section

Fully

Implemented

implemented

Related Vulnerabilities

Search for vulnerabilities resulting from the violation of this rule on the CERT website.

...

CERT C++ Secure Coding Standard: PRE30-CPP. Do not create a universal character name through concatenation

ISO/IEC 10646-2003

ISO/IEC 9899:19992011 Section 5.1.1.2, "Translation phases," Section 6.4.3, "Universal character names," and Section 6.10.3.3, "The ## operator"

Bibliography

...