CWG2870 [lex.string] "" "" (adjacent ordinary string literals) are ill-formed (original) (raw)

Reference (section label): [lex.string]

Issue description

Subclause 5.13.5 [lex.string] paragraph 7 states that:

If two string-literals have the same encoding-prefix, the common encoding-prefix is that encoding-prefix.
If one string-literal has no encoding-prefix, the common encoding-prefix is that of the other string-literal.
Any other combinations are ill-formed.

In the case "" "", i.e. when neither string-literal has an encoding-prefix:

Therefore, this construct is ill-formed. Arguably, it is not possible to "fill in the blanks" and interpret the latter sentence as:

If at least one string-literal has no encoding-prefix the common encoding-prefix is that of the other string-literal, or none if neither has an encoding-prefix.

On another note, it is unusual that we talk about a "common encoding-prefix", even in the case where there is no encoding-prefix at all. The common prefix in this paragraph should not be formatted as a grammar rule.

Suggested resolution

Itemize subclause 5.13.5 [lex.string] paragraph 7, and update the result as follows:

The common encoding-prefix encoding prefix for a sequence of adjacent _string-literal_s is determined pairwise as follows:

Alternative resolution (not proposed, but worth considering)

In subclause 5.13.5 [lex.string] paragraph 7, replace all occurrences of encoding-prefix with "encoding prefix". This legitimizes applying paragraph 7, sentence 1 or 2 to the case "" "".