Shafik Yaghmour

Compiler Engineer at Intel. This is a personal blog. The opinions stated here are my own, not those of my company.

The answer to this is C, it is conditionally supported. A compiler could make this ill-formed or well-defined.

Looking at [lex.ccon]p2:

… An ordinary character literal that contains more than one c-char is a multicharacter literal. A multicharacter literal, or an ordinary character literal containing a single c-char not representable in the execution character set, is conditionally-supported, has type int, and has an implementation-defined value.

tells us multicharacter literals have implementation defined values. But we also have to look at [lex.ccon]p7:

…Escape sequences in which the character following the backslash is not listed in Table 8 are conditionally-supported, with implementation-defined semantics…

which tells us that escape sequences not mentioned in the table are conditionally supported.

So while

\77

Is a valid octal escape sequence and has a value of 63

\97

Is not a valid escape sequence it looks like clang and gcc just ignore the \ and treat it like '97' and then we end up with a implementation defined multicharacter literal value. It looks like clang generates a value of 14647 which does not fit in a char and is truncated to a value of 55 So we end up with 55 < 63 Which in this case is true but is not portable.

The gcc manual describes how gcc calculates the value of multicharacter literal.