Created on2013-12-17.00:00:00 last changed109 months ago
[Moved to DR at the November, 2014 meeting.]
Additional note, February, 2014:
Two editorial changes have been made since CWG approved the proposedresolution:
The deletion of the requirement in 9.2.3 [dcl.fct.spec] paragraph 4that string literals in inline functions be the same madethe note following that requirement irrelevant, so the deletion has beenextended to include the note as well.
The issue has been returned to "review" status to allow possiblereconsideration of these editorial changes.
Proposed resolution (February, 2014):
Change 5.13.5 [lex.string] paragraph 1 as follows:
Astring literalstring-literal is a sequenceof characters...
Change 5.13.5 [lex.string] paragraph 2 as follows:
Astring literalstring-literal that hasanR in the prefix...
Change 5.13.5 [lex.string] paragraph 6 as follows:
After translation phase 6, astringliteralstring-literal that does not begin...
Change 5.13.5 [lex.string] paragraph 7 as follows:
Astring literalstring-literal that beginswithu8...
Change 5.13.5 [lex.string] paragraph 10 as follows:
Astring literalstring-literal that beginswithu, such asu"asdf", is achar16_t stringliteral. Achar16_t string literal has type “arrayofnconst char16_t”, wheren is the size ofthe string as defined below; ithas static storage durationandis initialized with the given characters. A singlec-charmay produce more than onechar16_t character in the form ofsurrogate pairs.
Change 5.13.5 [lex.string] paragraph 11 as follows:
Astring literalstring-literal that beginswithU, such asU"asdf", is achar32_t stringliteral. Achar32_t string literal has type “arrayofnconst char32_t”, wheren is the size ofthe string as defined below; ithas static storage durationandis initialized with the given characters.
Change 5.13.5 [lex.string] paragraph 12 as follows:
Astring literalstring-literal that beginswithL, such asL"asdf", is a wide string literal. A widestring literal has type “array ofnconstwchar_t”, wheren is the size of the string as definedbelow; ithas static storage duration andis initialized withthe given characters.
Delete 5.13.5 [lex.string] paragraph 13:
Whether all string literals are distinct (that is, are stored innonoverlapping objects) is implementation-defined. The effect of attemptingto modify a string literal is undefined.
Change 5.13.5 [lex.string] paragraph 14 as follows:
In translation phase 6 (5.2 [lex.phases]), adjacentstringliteralsstring-literals are concatenated. Ifbothstring literalsstring-literals have thesameencoding-prefix, the resulting concatenated string literal hasthatencoding-prefix. If onestringliteralstring-literal hasnoencoding-prefix, it is treated as astringliteralstring-literal of thesameencoding-prefix as the other operand. If a UTF-8 string literaltoken is adjacent to a wide string literal token, the program isill-formed. Any other concatenations are conditionally-supported withimplementation-defined behavior. [Note: This concatenation is aninterpretation, not a conversion. Because the interpretation happens intranslation phase 6 (after each character from a literal has beentranslated into a value from the appropriate character set), astringliteralstring-literal's initial rawness has noeffect on the interpretation or well-formedness of theconcatenation. —end note] Table 8...
Add the following as a new paragraph at the end of5.13.5 [lex.string]:
Evaluating astring-literal results in a string literalobject with static storage duration, initialized from the given charactersas specified above. Whether all string literals are distinct (that is,are stored in nonoverlapping objects) and whether successive evaluationsof astring-literal yield the same or a different object isunspecified. [Note: The effect of attempting to modify a stringliteral is undefined. —end note]
Change 9.2.3 [dcl.fct.spec] paragraph 4 as follows:
...Astatic local variable in anextern inline functionalways refers to the same object.A string literal in the body ofanextern inline function is the same object in differenttranslation units. [Note: A string literal appearing in a defaultargument is not in the body of an inline function merely because theexpression is used in a function call from that inlinefunction. —end note]A type defined within the body ofanextern inline function is the same type in every translationunit.
According to 9.2.3 [dcl.fct.spec] paragraph 4,
A string literal in the body of an extern inline function isthe same object in different translation units.
The Standard does not otherwise specify when string literals arerequired to be the same object, and this requirement is not widelyimplemented. Should it be removed?
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2017-02-06 00:00:00 | admin | set | status: drwp -> cd4 |
| 2015-05-25 00:00:00 | admin | set | status: dr -> drwp |
| 2015-04-13 00:00:00 | admin | set | messages: +msg5357 |
| 2014-11-24 00:00:00 | admin | set | status: ready -> dr |
| 2014-07-07 00:00:00 | admin | set | status: review -> ready |
| 2014-03-03 00:00:00 | admin | set | messages: +msg4865 |
| 2014-03-03 00:00:00 | admin | set | messages: +msg4864 |
| 2014-03-03 00:00:00 | admin | set | status: open -> review |
| 2013-12-17 00:00:00 | admin | create | |