<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<TITLE>
    CWG Issue 790</TITLE>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<STYLE TYPE="text/css">
  INS { text-decoration:none; font-weight:bold; background-color:#A0FFA0 }
  .INS { text-decoration:none; background-color:#D0FFD0 }
  DEL { text-decoration:line-through; background-color:#FFA0A0 }
  .DEL { text-decoration:line-through; background-color: #FFD0D0 }
  @media (prefers-color-scheme: dark) {
    HTML { background-color:#202020; color:#f0f0f0; }
    A { color:#5bc0ff; }
    A:visited { color:#c6a8ff; }
    A:hover, a:focus { color:#afd7ff; }
    INS { background-color:#033a16; color:#aff5b4; }
    .INS { background-color: #033a16; }
    DEL { background-color:#67060c; color:#ffdcd7; }
    .DEL { background-color:#67060c; }
  }
  SPAN.cmnt { font-family:Times; font-style:italic }
</STYLE>
</HEAD>
<BODY>
<P><EM>This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21
  Core Issues List revision 118b.
  See http://www.open-std.org/jtc1/sc22/wg21/ for the official
  list.</EM></P>
<P>2025-09-28</P>
<HR>
<A NAME="790"></A><H4>790.
  
Concatenation of raw and non-raw string literals
</H4>
<B>Section: </B>5.13.5&#160; [<A href="https://wg21.link/lex.string">lex.string</A>]
 &#160;&#160;&#160;

 <B>Status: </B>CD2
 &#160;&#160;&#160;

 <B>Submitter: </B>JP
 &#160;&#160;&#160;

 <B>Date: </B>3 March, 2009<BR><BR>


<A href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2010/n3086.html#JP5">N2800 comment
  JP&#160;5<BR></A>

<P>[Voted into WP at October, 2009 meeting.]</P>

<P>The description of concatenation of string literals in
5.13.5 [<A href="https://wg21.link/lex.string#11">lex.string</A>] paragraph 11 does not mention raw
strings explicitly, so it is not clear whether, and if so, how, they
combine with non-raw strings.</P>

<P><B>Notes from the March, 2009 meeting:</B></P>

<P>A raw string should be considered equivalent to the corresponding
non-raw string in string literal concatenation.</P>

<P><B>Proposed resolution (September, 2009):</B></P>

<OL>
<LI><P>In 5.13.5 [<A href="https://wg21.link/lex.string">lex.string</A>], replace the definition of
<I>string-literal</I> with:</P></LI>

<UL>
<I>string-literal:</I>
<UL>
<I>encoding-prefix<SUB>opt</SUB></I> <TT>"</TT> <I>s-char-sequence<SUB>opt</SUB></I> <TT>"</TT>
</UL>
<UL>
<I>encoding-prefix<SUB>opt</SUB></I> <TT>R</TT> <I>raw-string</I>
</UL>
</UL>
<BR>

<UL>
<I>encoding-prefix:</I>
<UL><TT>u8</TT></UL>
<UL><TT>u</TT></UL>
<UL><TT>U</TT></UL>
<UL><TT>L</TT></UL>
</UL>

<LI><P>Change 5.13.5 [<A href="https://wg21.link/lex.string#5">lex.string</A>] paragraph 5 as follows:</P></LI>

<BLOCKQUOTE>

<DEL>A</DEL> <INS>After translation phase 6, a</INS> string literal
that does not begin with <DEL><TT>u8</TT>, <TT>u</TT>, <TT>U</TT>, or
<TT>L</TT></DEL> <INS>an <I>encoding-prefix</I></INS> is an ordinary
string literal, and is initialized with the given characters.

</BLOCKQUOTE>

<LI><P>Change 5.13.5 [<A href="https://wg21.link/lex.string#12">lex.string</A>] paragraph 12 as follows:</P></LI>

<BLOCKQUOTE>

In translation phase 6 (5.2 [<A href="https://wg21.link/lex.phases">lex.phases</A>]), adjacent string
literals are concatenated.  If both string literals have the same
<DEL>prefix</DEL> <INS><I>encoding-prefix</I></INS>, the resulting
concatenated string literal has that <DEL>prefix</DEL>
<INS><I>encoding-prefix</I></INS>. If one string literal has no
<DEL>prefix</DEL> <INS><I>encoding-prefix</I></INS>, it is treated as
a string literal of the same <DEL>prefix</DEL>
<INS><I>encoding-prefix</I></INS> as the other operand.  If a UTF-8
string literal token is adjacent to a wide string literal token, the
program is ill-formed.  Any other concatenations are conditionally
supported with implementation-defined behavior.  [<I>Note:</I> This
concatenation is an interpretation, not a conversion. <INS>Because the
interpretation happens in translation phase 6 (after each character
from each literal has been translated into a value from the
appropriate character set), a string literal's initial rawness has no
effect on the interpretation or well-formedness of the
concatenation.</INS> &#8212;<I>end note</I>] [<I>Example:</I>...

</BLOCKQUOTE>

</OL>

<P>(Note: this resolution also resolves <A HREF="834.html">issue 834</A>.)</P>

<BR><BR>
</BODY>
</HTML>
