Versions Compared

Key

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

...

Code Block
bgColor#FFCCCC
#define assign(uc1, uc2, uc3, uc4, val) \
  uc1##uc2##uc3##uc4 = val;

int \U00010401u0401\U00010401u0401\U00010401u0401\U00010402u0402;
assign( \U00010401u0401, \U00010401u0401, \U00010401u0401, \U00010402u0402, 4);

Implementation Details

While noncompliant, this code does produce the expected behavior; that is, it assigns the variable the value 4 on both MSVC 2008, and on Linux/GCC 4.3, when compiled with -std=c99 -fextended-identifiers.

Compliant Solution

This code solution is compliant.

Code Block
bgColor#ccccff
#define assign(ucn, val) ucn = val;

int \U00010401u0401\U00010401u0401\U00010401u0401\U00010402u0402;
assign( \U00010401u0401\U00010401u0401\U00010401u0401\U00010402u0402, 4);

Risk Assessment

Creating a universal character name through token concatenation results in undefined behavior.

...