Description
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:
- The first sentence in the quote cannot apply because neither string-literal has an encoding-prefix, and encoding-prefix cannot be empty.
- The second sentence in the quote cannot apply because the other string-literal has no 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-prefixencoding prefix for a sequence of adjacent string-literals is determined pairwise as follows:
- If two string-literals have the same encoding-prefix, the common
encoding-prefixencoding prefix is that encoding-prefix.IfOtherwise, if one string-literal has no encoding-prefix, the commonencoding-prefixencoding prefix is that of the other string-literal.- Otherwise, if neither string-literal has an encoding-prefix, there is no common encoding prefix.
Any other combinations areOtherwise, the program is ill-formed.
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 "" ""
.