-
Notifications
You must be signed in to change notification settings - Fork 0
/
p2029r1.html
1865 lines (1764 loc) · 73.9 KB
/
p2029r1.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!doctype html public "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<head>
<title>
Proposed resolution for core issues 411, 1656, and 2333; numeric and universal
character escapes in character and string literals
</title>
<style type="text/css">
table#header th,
table#header td
{
text-align: left;
}
#hideins:checked ~ * ins, #hideins:checked ~ * ins * { display:none; visibility:hidden }
#hidedel:checked ~ * del, #hidedel:checked ~ * del * { display:none; visibility:hidden }
ins, ins *
{
text-decoration: underline;
color: #000000;
background-color:#C8FFC8
}
del, del *
{
text-decoration: line-through;
color: #000000;
background-color:#FFA0A0
}
nop, nop *
{
color: #000000;
background-color:#B0B0FF
}
blockquote
{
color: #000000;
background-color: #F1F1F1;
border: 1px solid #D1D1D1;
padding-left: 0.5em;
padding-right: 0.5em;
}
blockquote.stdins
{
/* text-decoration: underline; */
color: #000000;
background-color: #C8FFC8;
border: 1px solid #B3EBB3;
padding: 0.5em;
}
blockquote.stddel
{
text-decoration: line-through;
color: #000000;
background-color: #FFA0A0;
border: 1px solid #ECD7EC;
padding-left: 0.5empadding-right: 0.5em;
}
blockquote.stdnop
{
color: #000000;
background-color: #B0B0FF;
border: 1px solid #ECD7EC;
padding-left: 0.5empadding-right: 0.5em;
}
</style>
</head>
<body>
<table id="header">
<tr>
<th>Document Number:</th>
<td>P2029R1</td>
</tr>
<tr>
<th>Date:</th>
<td>2020-02-28</td>
</tr>
<tr>
<th>Audience:</th>
<td>CWG</td>
</tr>
<tr>
<th>Reply-to:</th>
<td>Tom Honermann <tom@honermann.net></td>
</tr>
</table>
<h1>
Proposed resolution for core issues 411, 1656, and 2333; numeric and universal
character escapes in character and string literals
</h1>
<ul>
<li><a href="#introduction">Introduction</a></li>
<li><a href="#changes">Changes from P2029R0</a></li>
<li><a href="#proposed">Proposed resolution overview</a></li>
<li>
<a href="#impact">Implementation impact</>
<ul>
<li><a href="#impact-escapes">Semantics of numeric-escape-sequences in UTF-8 literals</a></li>
<li><a href="#impact-badchar">Character literal type for characters not representable in the execution character set</a></li>
</ul>
</li>
<li><a href="#ack">Acknowledgements</a></li>
<li>
<a href="#pr">Proposed resolution</a>
<ul>
<li><a href="#lex.phases">[lex.phases]</a></li>
<li><a href="#lex.ccon">[lex.ccon]</a></li>
<li><a href="#lex.string">[lex.string]</a></li>
</ul>
</li>
</ul>
<h1 id="introduction">Introduction</h1>
<p>
This paper proposes substantial changes to
<a href="http://eel.is/c++draft/lex.phases">[lex.phases]</a>,
<a href="http://eel.is/c++draft/lex.ccon">[lex.ccon]</a>, and
<a href="http://eel.is/c++draft/lex.string">[lex.string]</a>
intended to address the following core issues as well as several other
more minor issues.
</p>
<ul>
<li>
<a href="http://wg21.link/cwg411">Core Issue 411: Use of universal-character-name in character versus string literals</a><br/>
</li>
<li>
<a href="http://wg21.link/cwg1656">Core Issue 1656: Encoding of numerically-escaped characters</a><br/>
</li>
<li>
<a href="http://wg21.link/cwg2333">Core Issue 2333: Escape sequences in UTF-8 character literals</a>
</li>
</ul>
<p>
This paper follows a prior
<a href="http://wiki.edg.com/pub/Wg21kona2019/CoreWorkingGroup/cwg2333.html">proposed resolution</a>
that only attempted to address
<a href="http://wg21.link/cwg2333">CWG 2333</a>.
That proposed resolution was
<a href="https://lists.isocpp.org/core/2019/01/5395.php">discussed on the core mailing list</a>
and at the
<a href="http://wiki.edg.com/bin/view/Wg21cologne2019/CoreIssuesProcessingTeleconference2019-06-24">June 24th, 2019 core issues processing teleconference</a>.
The resolution proposed in this paper attempts to address the feedback
provided during those discussions.
</p>
<p>
The notes for <a href="http://wg21.link/cwg2333">CWG 2333</a> in the current
active issues list (revision 100) state that discussion at the
<a href="http://wiki.edg.com/bin/view/Wg21albuquerque/IssuesTeleconference2017-08-14">
August 14th, 2017 core issues processing teleconference</a> resulted in a
determination that numeric escape sequences in UTF-8 character literals
should be ill-formed. The issue has remained in drafting status since then.
</p>
<p>
SG16 discussed this issue during its
<a href="https://github.com/sg16-unicode/sg16-meetings#october-17th-2018">October 17th, 2018 teleconference</a>.
The SG16 consensus was for a different resolution than is currently described
in the active issues list. The SG16 consensus was based on the following
observations:
<ul>
<li>The current resolution in the active issues list contradicts existing
practice. gcc, Clang, and Visual C++ all allow octal and hexadecimal
escape sequences in UTF-8 literals.</li>
<li>Octal and hexadecimal escape sequences in UTF-8 literals are useful for
a number of purposes:
<ul>
<li>Embedding null characters: <tt>u8"\0"</tt></li>
<li>Creating ill-formed code unit sequences for testing purposes.</li>
<li>Creating Modified UTF-8, CESU-8, and WTF-8 string literals. This
entails two abilities:
<ul>
<li>Embedding <tt>U+0000</tt> as an overlong UTF-8 sequence:
<tt>u8"\xC0\x80"</tt></li>
<li>Embedding lone surrogate code points as individual UTF-8 code
unit sequences. For example, encoding <tt>U+D800</tt> as
<tt>u8"\xED\xA0\x80"</tt>. (Note that use of <tt>\u</tt> escapes
specifying surrogate code points is ill-formed).</li>
</ul>
</li>
<li>Compatibility with existing log/debug systems that output literals
with non-printable characters represented with escapes so as to
facilitate copy/paste of such output into code.</li>
</ul>
</li>
</ul>
SG16 conducted the following poll:
<div style="margin-left: 1em;">
Continue to allow hex and octal escapes that indicate code unit values,
requiring only that they fit into the range of the code unit type?
<table border="1">
<tr>
<th>SF</th>
<th>F</th>
<th>N</th>
<th>A</th>
<th>SA</th>
</tr>
<tr>
<td>8</td>
<td>1</td>
<td>0</td>
<td>0</td>
<td>0</td>
</tr>
</table>
</div>
In the polled question, "Continue" refers to existing implementation behavior;
to maintain the current implementation status quo exhibited by gcc, Clang and
Visual C++.
</p>
<p>
The proposed resolution reflects the SG16 consensus.
</p>
<p>
<a href="http://wg21.link/cwg411">CWG 411</a> is addressed by specifying
different behavior for character literals vs string literals for characters
that are not representable by a single code unit. For example, when the
execution character set is UTF-8, <tt>'\u0153'</tt> is conditionally-supported,
has type <tt>int</tt> and an implementation-defined value, but
<tt>"\u0153"</tt> is a character array of length 3 containing the
UTF-8 encoding of U+0153 (LATIN SMALL LIGATURE OE) and a null character
(<tt>\xC5\x93\x00</tt>).
</p>
<p>
<a href="http://wg21.link/cwg1656">CWG 1656</a> is addressed by clarifying
that numeric escape sequences denote code unit values in the execution
character set; that the values are not subject to conversion from the
encoding of the source file to the execution character set.
</p>
<h1 id="changes">Changes from <a href="https://wg21.link/p2029r0">P2029R0</a></h1>
<p>
<ul>
<li>Addressed core wording review provided at the
<a href="http://wiki.edg.com/bin/view/Wg21prague/IssuesProcessingTeleconference2020-01-16">January 16th, 2020 core issues processing teleconference</a>.
<ul>
<li>[lex.phases]p5: Reworded and made portions of the wording
a non-normative note.</li>
<li>[lex.ccon]: Added new
<tt>character-escape-sequence</tt> and
<tt>simple-escape-sequence-char</tt>
grammar productions to simplify wording.</li>
<li>[lex.ccon]: Added new
<tt>conditional-escape-sequence</tt> and
<tt>conditional-escape-sequence-char</tt>
grammar productions to address previously missing grammar support
for conditionally-supported implementation-defined escape
sequences.</li>
<li>[lex.ccon]: Added new <tt>conditional character literal</tt>,
<tt>multicharacter literal</tt>,
<tt>conditional wide character literal</tt>, and
<tt>wide multicharacter literal</tt>
character literal kinds to simplify wording.</li>
<li>[lex.ccon]: Modified wide multicharacter literals to be
conditionally supported.</li>
<li>[lex.ccon]: Modified wide character literals for which the
<tt>c-char-sequence</tt> specifies a character that lacks
representation in the execution wide-character set or that cannot
be encoded in a single code unit to be conditionally supported.</li>
<li>[lex.ccon]p1: Restored original wording and added a drafting note
that this paragraph will be editorially deleted and all occurrences
of "character literal" replaced with references to the
<tt><em>character-literal</em></tt> grammar production.</li>
<li>[lex.ccon]p2-p6: Replaced these paragraphs with a table that defines
the kinds of character literals and their properties.</li>
<li>[lex.ccon]p7: Integrated wording for conditionally-supported
implementation-defined escape sequences into this paragraph;
this content was previously in a new paragraph.</li>
<li>[lex.ccon]p7: Removed the incorrect note about NL, HT, VT, and FF
potentially lacking representation in the execution character set
and the execution wide-character set. The note was added following
a misreading of [lex.phases].</li>
<li>[lex.ccon]p7: Removed the note about UTF encodings being able to
represent all simple-escape-sequences using a single code unit.</li>
<li>[lex.ccon]p7: Moved the contents of footnote 19 (explaining why
<tt>\?</tt> is recognized as a simple escape sequence) into a
note.</li>
<li>[lex.string]: Modified ordinary and wide string literals that specify
characters that are not representable in the applicable character
encoding to be conditionally supported.</li>
<li>[lex.string]p6,7,9-11: Replaced these paragraphs with a table that
defines the kinds of string literals and their properties.</li>
</ul>
</li>
<li>Updated the implementation impact section to note Visual C++'s current
handling of character literals for characters that lack representation
in the execution character set.</li>
</ul>
</p>
<h1 id="proposed">Proposed resolution overview</h1>
<p>
The proposed wording changes are intended to resolve
<a href="http://wg21.link/cwg411">CWG 411</a>,
<a href="http://wg21.link/cwg1656">CWG 1656</a>, and
<a href="http://wg21.link/cwg2333">CWG 2333</a> by:
<ul>
<li>Clarifying that hexadecimal and octal escape sequences:
<ul>
<li>are valid in <tt>u8</tt>, <tt>u</tt>, and <tt>U</tt> character
literals. (CWG 2333)</li>
<li>specify values that need not correspond to valid code unit
values for the applicable character encoding. (CWG 2333)</li>
<li>specify the execution-time value of character literals or individual
code unit values of string literals; that the value expressed is not
subject to conversion to the applicable execution character set.
(CWG 1656)</li>
<li>specify values that may result in string literals that are ill-formed
according to their applicable character encoding (CWG 2333).</li>
</ul>
<li>Clarifying that characters that cannot be specified in a character
literal because they require more than one code unit in the applicable
character encoding may be specified in string literals. (CWG 411)</li>
</ul>
</p>
<p>
Additionally, the wording updates are intended to:
<ul>
<li>Specify behavior for non-ordinary character and string literals when a
character lacks representation in the applicable character encoding.
(Wording was previously missing)</li>
<li>Specify that wide multicharacter literals are conditionally
supported.</li>
<li>Specify that ordinary and wide string literals that specify characters
that are not representable in the applicable character encoding are
conditionally supported.</li>
<li>Specify that wide character literals that have a <tt>c-char-sequence</tt>
that specifies a character that is not representable in the execution
wide-character set or that cannot be encoded in a single code unit are
conditionally supported.</li>
<li>Remove non-normative wording that states that <tt>wchar_t</tt> is able to
represent all members of the execution wide-character set as this
contradicts wide spread existing practice (SG16 has an issue tracking
this at
<a href="https://github.com/sg16-unicode/sg16/issues/9">https://github.com/sg16-unicode/sg16/issues/9</a>).
<li>Modernize the wording with current style preferences and terminology.</li>
</ul>
</p>
<p>
The concept of an "associated character encoding" is introduced for character
and string literals so as to enable wording to be independent of the particular
kind of literal (ordinary, wide or Unicode).
</p>
<p>
New <tt>basic-c-char</tt>, <tt>basic-s-char</tt>,
<tt>character-escape-sequence</tt>, <tt>numeric-escape-sequence</tt>, and
<tt>simple-escape-sequence-char</tt> grammar productions are proposed in order
to simplify wording. The <tt>c-char</tt>, <tt>s-char</tt>, and
<tt>escape-sequence</tt> grammar productions are updated to define them in
terms of the new grammar productions.
</p>
<p>
New <tt>conditional-escape-sequence</tt> and
<tt>conditional-escape-sequence-char</tt> grammar production are proposed to
address previously missing grammar support for conditionally-supported
implementation-defined escape sequences.
</p>
<p>
New <tt>multicharacter literal</tt> and
<tt>wide multicharacter literal</tt>
character literal kinds are defined in order to simplify wording. These new
kinds cover the cases where an ordinary or wide character literal has a
<tt>c-char-sequence</tt> containing more than one
<tt>c-char</tt>.
</p>
<p>
New <tt>conditional character literal</tt> and
<tt>conditional wide character literal</tt>
character literal kinds are defined in order to simplify wording. These new
kinds cover the cases where the character specified by the
<tt>c-char-sequence</tt> lacks representation in the
execution (wide-)character set or cannot be encoded in a single code unit.
</p>
<h1 id="impact">Implementation impact</h1>
<p>
The author intends the proposed wording to reflect existing practice for the
gcc and Clang compilers. If this proposal is adopted, neither of those
compilers are expected to require updates.
However, there is implementation impact to the Microsoft Visual C++ compiler.
</p>
<h2 id="impact-escapes">Semantics of numeric-escape-sequences in UTF-8 literals</h2>
<p>
Consider the following (C++20) code:
<div style="margin-left: 1em;">
<pre><code>constexpr const char8_t c[] = u8"\xc3\x80"; // UTF-8 encoding of U+00C0 {LATIN CAPITAL LETTER A WITH GRAVE}
#if defined(_MSC_VER)
// Microsoft Visual C++:
static_assert(c[0] == 0xC3); // UTF-8 encoding of U+00C3 {LATIN CAPITAL LETTER A WITH TILDE}
static_assert(c[1] == 0x83);
static_assert(c[2] == 0xC2); // UTF-8 encoding of U+0080 {<control>}
static_assert(c[3] == 0x80);
static_assert(c[4] == 0x00); // null
#else
// Gcc and Clang:
static_assert(c[0] == 0xC3); // UTF-8 encoding of U+00C0 {LATIN CAPITAL LETTER A WITH GRAVE}
static_assert(c[1] == 0x80);
static_assert(c[2] == 0x00); // null
#endif
</code></pre>
</div>
Gcc and Clang encode the hexadecimal escapes as code units in the target (UTF-8)
encoding and perform no conversions (consistent with the behavior intended by
this proposal). However, Visual C++ considers each hexadecimal escape to
specify a code point in the source encoding and encodes each as UTF-8.
</p>
<p>
The author does not know if the Visual C++ behavior exhibited for UTF-8 literals
is intentional or reflective of a defect. The behavior is inconsistent for
UTF-8 and UTF-16 literals. For UTF-8 literals, numeric escape sequences that
specify values outside the range of <tt>char8_t</tt> are accepted as code
point values and encoded as UTF-8. However, for UTF-16 literals, numeric escape
sequences that specify values outside the range of <tt>char16_t</tt> are
rejected rather than being considered a code point value and encoded as a UTF-16
surrogate pair.
</p>
<h2 id="impact-badchar">Character literal type for characters not representable in the execution character set</h2>
<p>
Consider the following code assuming that the execution character set does not
have representation for the specified Unicode code points.
<div style="margin-left: 1em;">
<pre><code>auto c1 = '\uFF10';
extern char c1;
#ifdef _MSC_VER
static_assert('\uFF10' == '?');
#endif
auto c2 = '\U0001F235';
extern int c2;
#ifdef _MSC_VER
static_assert('\U0001F235' == '??');
#endif
</code></pre>
</div>
This code should be rejected (both before and after this proposal) because the
redeclaration of <tt>c1</tt> with type <tt>char</tt> does not match the first
declaration for which <tt>c1</tt> should have a deduced type of <tt>int</tt>.
Visual C++ accepts it when compiled with <tt>/execution-charset:windows-1252</tt>
with the following warnings:
<div style="margin-left: 1em;">
<pre><code><source>(1): warning C4566: character represented by universal-character-name '\uFF10' cannot be represented in the current code page (1252)
<source>(4): warning C4566: character represented by universal-character-name '\uFF10' cannot be represented in the current code page (1252)
<source>(6): warning C4566: character represented by universal-character-name '\U0001F235' cannot be represented in the current code page (1252)
<source>(9): warning C4566: character represented by universal-character-name '\U0001F235' cannot be represented in the current code page (1252)
</code></pre>
</div>
It seems that the Visual C++ compiler translates unrepresentable characters
from the Unicode BMP to a single <tt>char</tt> with value equal to
<tt>'?'</tt>, but translates unrepresentable characters from outside the
Unicode BMP to <tt>int</tt> with value equal to the multicharacter literal
<tt>'??'</tt>. This seems unlikely to be intended behavior. It would be
conforming if, for the Unicode BMP case, an <tt>int</tt> with value equal
to <tt>'?'</tt> was produced.
</p>
<p>
Gcc and Clang both reject the above code regardless of whether those Unicode
characters have representation in the execution character set. If they are
representable, then the code is rejected (as permitted) because the characters
cannot be encoded in a single code unit. If they are not representable (which
only happens for gcc since Clang always targets UTF-8), then the code is
rejected because the redeclaration of <tt>c1</tt> as <tt>char</tt> does not
match the deduced <tt>int</tt> type for its first declaration.
</p>
<h1 id="ack">Acknowledgements</h1>
<p>Thank you to Jens Maurer and Steve Downey for providing feedback on initial
drafts of this paper!
</p>
<h1 id="pr">Proposed resolution</h1>
<p>These changes are relative to
<a title="Working Draft, Standard for Programming Language C++"
href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/n4835.pdf">
N4835</a>.
</p>
<p>The changes to
<a href="http://eel.is/c++draft/lex.ccon">[lex.ccon]</a> and
<a href="http://eel.is/c++draft/lex.string">[lex.string]</a>
are rather pervasive. For ease of review, unchanged paragraphs in these
sections are retained in the wording below. These paragraphs are
introduced with "<em>No</em> changes to ..." and are <nop>highlighted with
a blue background</nop>.
</p>
<p>These changes do not reflect recent editorial changes made in
<a href="https://github.com/cplusplus/draft/pull/2768">
https://github.com/cplusplus/draft/pull/2768</a>;
merge conflict resolution will be required.
</p>
<input type="checkbox" id="hideins">Hide inserted text</input><br/>
<input type="checkbox" id="hidedel">Hide deleted text</input>
<h2 id="lex.phases">[lex.phases]</h2>
<p>Change in
<a href="http://eel.is/c++draft/lex.phases#1.5">
5.2 [lex.phases] paragraph 5</a>:<br/>
<em>Drafting Note:</em> The change of "escape sequence" to
"<tt>character-escape-sequence</tt>" addresses
<a href="http://wg21.link/cwg1656">CWG 1656</a>.
<blockquote>
Each <del>basic source character set member</del><ins><a href="http://eel.is/c++draft/lex.ccon#nt:basic-c-char"><em>basic-c-char</em></a>,
<a href="http://eel.is/c++draft/lex.string#nt:basic-s-char"><em>basic-s-char</em></a>, and
<a href="http://eel.is/c++draft/lex.string#nt:r-char"><em>r-char</em></a>
</ins>
in a character literal or a string literal, as well as each
<del>escape sequence</del><ins><a href="http://eel.is/c++draft/lex.ccon#nt:character-escape-sequence"><em>character-escape-sequence</em></a></ins>
and
<a href="http://eel.is/c++draft/lex.charset#nt:universal-character-name"><em>universal-character-name</em></a>
in a character literal or a non-raw string literal, is converted to the
<del>corresponding member of the execution character set
(<a href="http://eel.is/c++draft/lex.ccon">[lex.ccon]</a>,
<a href="http://eel.is/c++draft/lex.string">[lex.string]</a>);
</del><ins>literal's
associated character encoding as specified in
<a href="http://eel.is/c++draft/lex.ccon">[lex.ccon]</a> and
<a href="http://eel.is/c++draft/lex.string">[lex.string]</a>.</ins>
<del>if there is no corresponding member, it is converted to an implementation
defined member other than the null (wide) character</del>
<ins>[ <em>Note:</em> If a character lacks representation in the associated
character encoding, then the character is converted to an
implementation-defined character or the literal is ill-formed
(<a href="http://eel.is/c++draft/lex.ccon">[lex.ccon]</a>,
<a href="http://eel.is/c++draft/lex.string">[lex.string]</a>)
— <em>end note</em> ]</ins>.
<sup><a href="http://eel.is/c++draft/lex.phases#footnote-8">8</a></sup>
</blockquote>
</p>
<p>Change in
<a href="http://eel.is/c++draft/lex.phases#1.7">
5.2 [lex.phases] paragraph 7</a>:<br/>
<em>Drafting note:</em> This addition duplicates wording in [lex.string], but
seems important to include here.
<blockquote>
<ins>A null character is appended to every
<a href="http://eel.is/c++draft/lex.string#nt:string-literal"><em>string-literal</em></a>.
</ins>White-space
characters separating tokens are no longer significant. Each
preprocessing token is converted into a token
(<a href="http://eel.is/c++draft/lex.token">[lex.token]</a>). The resulting
tokens are syntactically and semantically analyzed and translated as a
translation unit. [ <em>Note:</em> The process of analyzing and translating
the tokens may occasionally result in one token being replaced by a sequence
of other tokens
(<a href="http://eel.is/c++draft/temp.names">[temp.names]</a>).
— <em>end note</em> ] It is implementation-defined whether the sources
for module units and header units on which the current translation unit has an
interface dependency
(<a href="http://eel.is/c++draft/module.unit">[module.unit]</a>,
<a href="http://eel.is/c++draft/module.import">[module.import]</a>)
are required to be available. [ <em>Note:</em> Source files, translation units
and translated translation units need not necessarily be stored as files, nor
need there be any one-to-one correspondence between these entities and any
external representation. The description is conceptual only, and does not
specify any particular implementation. — <em>end note</em> ]
</blockquote>
</p>
<h2 id="lex.ccon">[lex.ccon]</h2>
<p>Change in
<a href="http://eel.is/c++draft/lex.ccon">
5.13.3 [lex.ccon]</a>:
<blockquote>
<a href="http://eel.is/c++draft/lex.ccon#nt:character-literal">character-literal:</a>
<div style="margin-left: 1em;">
<a href="http://eel.is/c++draft/lex.ccon#nt:encoding-prefix">encoding-prefix</a><sub>opt</sub>
<tt>'</tt>
<a href="http://eel.is/c++draft/lex.ccon#nt:c-char-sequence">c-char-sequence</a>
<tt>'</tt>
</div>
<br/>
<a href="http://eel.is/c++draft/lex.ccon#nt:encoding-prefix">encoding-prefix:</a> one of
<div style="margin-left: 1em;">
<tt>u8</tt>  <tt>u</tt>  <tt>U</tt>  <tt>L</tt>
</div>
<br/>
<a href="http://eel.is/c++draft/lex.ccon#nt:c-char-sequence">c-char-sequence:</a>
<div style="margin-left: 1em;">
<a href="http://eel.is/c++draft/lex.ccon#nt:c-char">c-char</a>
</div>
<div style="margin-left: 1em;">
<a href="http://eel.is/c++draft/lex.ccon#nt:c-char-sequence">c-char-sequence</a>
<a href="http://eel.is/c++draft/lex.ccon#nt:c-char">c-char</a>
</div>
<br/>
<a href="http://eel.is/c++draft/lex.ccon#nt:c-char">c-char:</a>
<del><div style="margin-left: 1em;">
any member of the basic source character set except the single-quote <tt>'</tt>,
backslash <tt>\</tt>, or
<a href="http://eel.is/c++draft/cpp.pre#nt:new-line">new-line</a>
character
</div></del>
<ins><div style="margin-left: 1em;">
basic-c-char
</div></ins>
<div style="margin-left: 1em;">
<a href="http://eel.is/c++draft/lex.ccon#nt:escape-sequence">escape-sequence</a>
</div>
<div style="margin-left: 1em;">
<a href="http://eel.is/c++draft/lex.charset#nt:universal-character-name">universal-character-name</a>
</div>
<br/>
<ins>basic-c-char:
<div style="margin-left: 1em;">
any member of the basic source character set except the single-quote <tt>'</tt>,
backslash <tt>\</tt>, or
<a href="http://eel.is/c++draft/cpp.pre#nt:new-line">new-line</a>
character
</div>
<br/></ins>
<a href="http://eel.is/c++draft/lex.ccon#nt:escape-sequence">escape-sequence:</a>
<del><div style="margin-left: 1em;">
<a href="http://eel.is/c++draft/lex.ccon#nt:simple-escape-sequence">simple-escape-sequence</a>
</div>
<div style="margin-left: 1em;">
<a href="http://eel.is/c++draft/lex.ccon#nt:octal-escape-sequence">octal-escape-sequence</a>
</div></del>
<del><div style="margin-left: 1em;">
<a href="http://eel.is/c++draft/lex.ccon#nt:hexadecimal-escape-sequence">hexadecimal-escape-sequence</a>
</div></del>
<div style="margin-left: 1em;">
<ins><a href="http://eel.is/c++draft/lex.ccon#nt:character-escape-sequence">character-escape-sequence</a></ins>
</div>
<div style="margin-left: 1em;">
<ins><a href="http://eel.is/c++draft/lex.ccon#nt:numeric-escape-sequence">numeric-escape-sequence</a></ins>
</div>
<br/>
<ins>
<a href="http://eel.is/c++draft/lex.ccon#nt:character-escape-sequence">character-escape-sequence</a>:
<div style="margin-left: 1em;">
<a href="http://eel.is/c++draft/lex.ccon#nt:simple-escape-sequence">simple-escape-sequence</a>
</div>
<div style="margin-left: 1em;">
<a href="http://eel.is/c++draft/lex.ccon#nt:conditional-escape-sequence">conditional-escape-sequence</a>
</div>
<br/>
</ins>
<a href="http://eel.is/c++draft/lex.ccon#nt:simple-escape-sequence">simple-escape-sequence:</a><del> one of</del>
<div style="margin-left: 1em;">
<del>
<tt>\'</tt>  <tt>\"</tt>  <tt>\?</tt>  <tt>\\</tt><br/>
<tt>\a</tt>  <tt>\b</tt>  <tt>\f</tt>  <tt>\n</tt>  <tt>\r</tt>  <tt>\t</tt>  <tt>\v</tt> <br/>
</del>
<ins>
<tt>\</tt> <a href="http://eel.is/c++draft/lex.ccon#nt:simple-escape-sequence-char">simple-escape-sequence-char</a>
</ins>
</div>
<ins><br/></ins>
<ins>
<a href="http://eel.is/c++draft/lex.ccon#nt:simple-escape-sequence-char">simple-escape-sequence-char</a>: one of
<div style="margin-left: 1em;">
<tt>'</tt> <tt>"</tt> <tt>?</tt> <tt>\</tt><br/>
<tt>a</tt> <tt>b</tt> <tt>f</tt> <tt>n</tt> <tt>r</tt> <tt>t</tt> <tt>v</tt>
</div>
<br/>
</ins>
<ins>
<a href="http://eel.is/c++draft/lex.ccon#nt:conditional-escape-sequence">conditional-escape-sequence</a>:
<div style="margin-left: 1em;">
<tt>\</tt> <a href="http://eel.is/c++draft/lex.ccon#nt:conditional-escape-sequence-char">conditional-escape-sequence-char</a>
</div>
<br/>
</ins>
<ins>
<a href="http://eel.is/c++draft/lex.ccon#nt:conditional-escape-sequence-char">conditional-escape-sequence-char</a>:
<div style="margin-left: 1em;">
any member of the basic source character set that is not in
<a href="http://eel.is/c++draft/lex.ccon#nt:simple-escape-sequence-char">simple-escape-sequence-char</a>
</div>
</ins>
<br/>
<ins>
<a href="http://eel.is/c++draft/lex.ccon#nt:numeric-escape-sequence">numeric-escape-sequence</a>:
<div style="margin-left: 1em;">
<a href="http://eel.is/c++draft/lex.ccon#nt:octal-escape-sequence">octal-escape-sequence</a>
</div>
<div style="margin-left: 1em;">
<a href="http://eel.is/c++draft/lex.ccon#nt:hexadecimal-escape-sequence">hexadecimal-escape-sequence</a>
</div>
<br/>
</ins>
<a href="http://eel.is/c++draft/lex.ccon#nt:octal-escape-sequence">octal-escape-sequence:</a>
<div style="margin-left: 1em;">
<tt>\</tt> <a href="http://eel.is/c++draft/lex.icon#nt:octal-digit">octal-digit</a>
</div>
<div style="margin-left: 1em;">
<tt>\</tt> <a href="http://eel.is/c++draft/lex.icon#nt:octal-digit">octal-digit</a>
<a href="http://eel.is/c++draft/lex.icon#nt:octal-digit">octal-digit</a>
</div>
<div style="margin-left: 1em;">
<tt>\</tt> <a href="http://eel.is/c++draft/lex.icon#nt:octal-digit">octal-digit</a>
<a href="http://eel.is/c++draft/lex.icon#nt:octal-digit">octal-digit</a>
<a href="http://eel.is/c++draft/lex.icon#nt:octal-digit">octal-digit</a>
</div>
<br/>
<a href="http://eel.is/c++draft/lex.ccon#nt:hexadecimal-escape-sequence">hexadecimal-escape-sequence:</a>
<div style="margin-left: 1em;">
<tt>\x</tt> <a href="http://eel.is/c++draft/lex.icon#nt:hexadecimal-digit">hexadecimal-digit</a>
</div>
<div style="margin-left: 1em;">
<a href="http://eel.is/c++draft/lex.ccon#nt:hexadecimal-escape-sequence">hexadecimal-escape-sequence</a>
<a href="http://eel.is/c++draft/lex.icon#nt:hexadecimal-digit">hexadecimal-digit</a>
</div>
</blockquote>
</p>
<p><em>No</em> changes to
<a href="http://eel.is/c++draft/lex.ccon#1">
5.13.3 [lex.ccon] paragraph 1</a>:<br/>
<em>Drafting Note:</em> Per discussion in the
<a href="http://wiki.edg.com/bin/view/Wg21prague/IssuesProcessingTeleconference2020-01-16">January 16th, 2020 core issues processing teleconference</a>,
this paragraph will be editorially deleted and all occurrences of
"character literal" will be replaced with references to the
<tt><em>character-literal</em></tt> grammar production.
<blockquote class="stdnop">
A character literal is one or more characters enclosed in single quotes, as in
<tt>'x'</tt>, optionally preceded by
<tt>u8</tt>, <tt>u</tt>, <tt>U</tt>, or <tt>L</tt></del>,
as in <tt>u8'w'</tt>, <tt>u'x'</tt>, <tt>U'y'</tt>, or <tt>L'z'</tt>, respectively.
</blockquote>
</p>
<p>Add a new paragraph and table (X) after
<a href="http://eel.is/c++draft/lex.ccon#1">
5.13.3 [lex.ccon] paragraph 1</a>:
<blockquote class="stdins">
Table X specifies the kinds of
<a href="http://eel.is/c++draft/lex.ccon#nt:character-literal"><em>character-literal</em></a>s
and their properties.
The type of a
<a href="http://eel.is/c++draft/lex.ccon#nt:character-literal"><em>character-literal</em></a>
is the associated code unit type.
<em>conditional character literal</em>s and
<em>conditional wide character literal</em>s
are distinguished from
<em>ordinary character literal</em>s and
<em>wide character literal</em>s
respectively by the presence of a
<a href="http://eel.is/c++draft/lex.ccon#nt:c-char-sequence"><em>c-char-sequence</em></a>
that contains a single
<a href="http://eel.is/c++draft/lex.ccon#nt:c-char"><em>c-char</em></a>
that is not a
<a href="http://eel.is/c++draft/lex.ccon#nt:numeric-escape-sequence"><em>numeric-escape-sequence</em></a>
and that specifies a character that either lacks representation in the
applicable associated character encoding or that cannot be encoded
in a single code unit.
<em>multicharacter literal</em>s and
<em>wide multicharacter literal</em>s
are distinguished from
<em>ordinary character literal</em>s and
<em>wide character literal</em>s
respectively by the presence of a
<a href="http://eel.is/c++draft/lex.ccon#nt:c-char-sequence"><em>c-char-sequence</em></a>
that contains more than one
<a href="http://eel.is/c++draft/lex.ccon#nt:c-char"><em>c-char</em></a>;
the
<a href="http://eel.is/c++draft/lex.ccon#nt:c-char-sequence"><em>c-char-sequence</em></a>
of all other character literals contains exactly one
<a href="http://eel.is/c++draft/lex.ccon#nt:c-char"><em>c-char</em></a>.
<em>conditional character literal</em>s,
<em>multicharacter literal</em>s,
<em>conditional wide character literal</em>s, and
<em>wide multicharacter literal</em>s
are conditionally supported.
</blockquote>
</p>
<blockquote class="stdins">
<div align="center">
<table border="0">
<tr>
<td align="left">Table X: Character literals
<td/>
<td align="right">[tab:lex.ccon.literals]</td>
</tr>
</table>
<br/>
<table border="1">
<tr>
<th>Kind</th>
<th>Encoding<br/>prefix</th>
<th>Associated<br/>code unit type</th>
<th>Associated<br/>character encoding</th>
<th>Example</th>
</tr>
<tr>
<td><em>ordinary character literal</em></td>
<td>none</td>
<td><tt>char</tt></td>
<td>encoding of the execution character set</td>
<td><tt>'v'</tt></td>
</tr>
<tr>
<td><em>conditional character literal</em></td>
<td>none</td>
<td><tt>int</tt></td>
<td>implementation-defined</td>
<td>
<tt>'\U0001F525'</tt><br/>
(assuming lack of representation in the execution character set,<br/>
or that representation would require more than one code unit.)
</td>
</tr>
<tr>
<td><em>multicharacter literal</em></td>
<td>none</td>
<td><tt>int</tt></td>
<td>implementation-defined</td>
<td><tt>'abcd'</tt></td>
</tr>
<tr>
<td><em>wide character literal</em></td>
<td><tt>L</tt></td>
<td><tt>wchar_t</tt></td>
<td>encoding of the execution wide-character set</td>
<td><tt>L'w'</tt></td>
</tr>
<tr>
<td><em>conditional wide character literal</em></td>
<td><tt>L</tt></td>
<td><tt>wchar_t</tt></td>
<td>implementation-defined</td>
<td>
<tt>L'\U0001F32A'</tt><br/>
(assuming lack of representation in the execution wide-character set,<br/>
or that representation would require more than one code unit.)
</td>
</tr>
<tr>
<td><em>wide multicharacter literal</em></td>
<td><tt>L</tt></td>
<td><tt>wchar_t</tt></td>
<td>implementation-defined</td>
<td><tt>L'abcd'</tt></td>
</tr>
<tr>
<td><em>UTF-8 character literal</em></td>
<td><tt>u8</tt></td>
<td><tt>char8_t</tt></td>
<td>UTF-8</td>
<td><tt>u8'x'</tt></td>
</tr>
<tr>
<td><em>UTF-16 character literal</em></td>
<td><tt>u</tt></td>
<td><tt>char16_t</tt></td>
<td>UTF-16</td>
<td><tt>u'y'</tt></td>
</tr>
<tr>
<td><em>UTF-32 character literal</em></td>
<td><tt>U</tt></td>
<td><tt>char32_t</tt></td>
<td>UTF-32</td>
<td><tt>U'z'</tt></td>
</tr>
</table>
</div>
</blockquote>
<p>Delete
<a href="http://eel.is/c++draft/lex.ccon#2">
5.13.3 [lex.ccon] paragraph 2</a>:<br/>
<em>Drafting Note:</em> The contents of paragraphs 2-6 were incorporated into
new paragraphs.
<blockquote class="stddel">
A character literal that does not begin with
<tt>u8</tt>, <tt>u</tt>,
<tt>U</tt>, or <tt>L</tt>
is an <em>ordinary character literal</em>.
An ordinary character literal that contains a single
<a href="http://eel.is/c++draft/lex.ccon#nt:c-char"><em>c-char</em></a>
representable in the execution character set
has type <tt>char</tt>, with value equal to the numerical value of the encoding
of the
<a href="http://eel.is/c++draft/lex.ccon#nt:c-char"><em>c-char</em></a>
in the execution character set. An ordinary character literal that
contains more than one
<a href="http://eel.is/c++draft/lex.ccon#nt:c-char"><em>c-char</em></a>
is a <em>multicharacter literal</em>. A multicharacter literal, or an
ordinary character literal containing a single
<a href="http://eel.is/c++draft/lex.ccon#nt:c-char"><em>c-char</em></a>
not representable in the execution character set, is conditionally-supported,
has type <tt>int</tt>, and has an implementation-defined value.
</blockquote>
</p>
<p>Delete
<a href="http://eel.is/c++draft/lex.ccon#3">
5.13.3 [lex.ccon] paragraph 3</a>:<br/>
<em>Drafting Note:</em> The contents of paragraphs 2-6 were incorporated into
new paragraphs. The note regarding the range of single code unit values was
removed.
<blockquote class="stddel">
A character literal that begins with <tt>u8</tt>, such as <tt>u8'w'</tt>, is a
character literal of type <tt>char8_t</tt>, known as a
<em>UTF-8 character literal</em>.
The value of a UTF-8 character literal is
equal to its ISO/IEC 10646 code point value, provided that the code point value
can be encoded as a single UTF-8 code unit. [ <em>Note:</em> That is, provided
the code point value is in the range 0x0-0x7F (inclusive). —
<em>end note</em> ] If the value is not representable with a single UTF-8 code
unit, the program is ill-formed. A UTF-8 character literal containing multiple
<a href="http://eel.is/c++draft/lex.ccon#nt:c-char"><em>c-char</em></a>s is
ill-formed.
</blockquote>
</p>
<p>Delete
<a href="http://eel.is/c++draft/lex.ccon#4">
5.13.3 [lex.ccon] paragraph 4</a>:<br/>
<em>Drafting Note:</em> The contents of paragraphs 2-6 were incorporated into
new paragraphs. The note regarding the range of singled code unit values was
removed.
<blockquote class="stddel">
A character literal that begins with the letter <tt>u</tt>, such as
<tt>u'x'</tt>, is a character literal of type <tt>char16_t</tt>, known as a
<em>UTF-16 character literal</em>. The value of a UTF-16 character literal
is equal to its ISO/IEC 10646 code point value, provided that the code point
value is representable with a single 16-bit code unit. [ <em>Note:</em> That
is, provided the code point value is in the range 0x0-0xFFFF (inclusive).
— <em>end note</em> ] If the value is not representable with a single
16-bit code unit, the program is ill-formed. A UTF-16 character literal
containing multiple
<a href="http://eel.is/c++draft/lex.ccon#nt:c-char"><em>c-char</em></a>s is
ill-formed.
</blockquote>
</p>
<p>Delete
<a href="http://eel.is/c++draft/lex.ccon#5">
5.13.3 [lex.ccon] paragraph 5</a>:<br/>
<em>Drafting Note:</em> The contents of paragraphs 2-6 were incorporated into
new paragraphs.
<blockquote class="stddel">
A character literal that begins with <tt>U</tt>, such as <tt>U'y'</tt>, is a
character literal of type <tt>char32_t</tt>, known as a
<em>UTF-32 character literal</em>.
The value of a UTF-32 character literal containing a single
<a href="http://eel.is/c++draft/lex.ccon#nt:c-char"><em>c-char</em></a>
is equal to its ISO/IEC 10646 code point value. A UTF-32 character literal
containing multiple
<a href="http://eel.is/c++draft/lex.ccon#nt:c-char"><em>c-char</em></a>s is
ill-formed.
</blockquote>
</p>
<p>Delete
<a href="http://eel.is/c++draft/lex.ccon#6">
5.13.3 [lex.ccon] paragraph 6</a>:<br/>