[diff.lex] # Annex C (informative) Compatibility [[diff]](./#diff) ## C.7 C++ and C [[diff.iso]](diff.iso#diff.lex) ### C.7.2 [[lex]](lex "5 Lexical conventions"): lexical conventions [diff.lex] [1](#1) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L2746) **Affected subclause:** [[lex.key]](lex.key) **Change:** New Keywords[.](#1.sentence-1) New keywords are added to C++; see [[lex.key]](lex.key "5.12 Keywords")[.](#1.sentence-2) **Rationale:** These keywords were added in order to implement the new semantics of C++[.](#1.sentence-3) **Effect on original feature:** Change to semantics of well-defined feature[.](#1.sentence-4) Any C programs that used any of these keywords as identifiers are not valid C++ programs[.](#1.sentence-5) **Difficulty of converting:** Syntactic transformation[.](#1.sentence-6) Converting one specific program is easy[.](#1.sentence-7) Converting a large collection of related programs takes more work[.](#1.sentence-8) **How widely used:** Common[.](#1.sentence-9) [2](#2) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L2766) **Affected subclause:** [[lex.ccon]](lex.ccon) **Change:** Type of [*character-literal*](lex.ccon#nt:character-literal "5.13.3 Character literals [lex.ccon]") is changed from int to char[.](#2.sentence-1) **Rationale:** This is needed for improved overloaded function argument type matching[.](#2.sentence-2) [*Example [1](#example-1)*: int function( int i );int function( char c ); function( 'x' ); It is preferable that this call match the second version of function rather than the first[.](#2.sentence-3) — *end example*] **Effect on original feature:** Change to semantics of well-defined feature[.](#2.sentence-4) C programs which depend onsizeof('x') == sizeof(int) will not work the same as C++ programs[.](#2.sentence-5) **Difficulty of converting:** Simple[.](#2.sentence-6) **How widely used:** Programs which depend upon sizeof('x') are probably rare[.](#2.sentence-7) [3](#3) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L2794) **Affected subclause:** [[lex.string]](lex.string) **Change:** Concatenated [*string-literal*](lex.string#nt:string-literal "5.13.5 String literals [lex.string]")*s* can no longer have conflicting [*encoding-prefix*](lex.ccon#nt:encoding-prefix "5.13.3 Character literals [lex.ccon]")es[.](#3.sentence-1) **Rationale:** Removal of non-portable feature[.](#3.sentence-2) **Effect on original feature:** Concatenation of [*string-literal*](lex.string#nt:string-literal "5.13.5 String literals [lex.string]")*s* with different [*encoding-prefix*](lex.ccon#nt:encoding-prefix "5.13.3 Character literals [lex.ccon]")es is now ill-formed[.](#3.sentence-3) **Difficulty of converting:** Syntactic transformation[.](#3.sentence-4) **How widely used:** Seldom[.](#3.sentence-5) [4](#4) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L2809) **Affected subclause:** [[lex.string]](lex.string) **Change:** String literals made const[.](#4.sentence-1) The type of a [*string-literal*](lex.string#nt:string-literal "5.13.5 String literals [lex.string]") is changed from “array of char” to “array of const char”[.](#4.sentence-2) The type of a UTF-8 string literal is changed from “array of char” to “array of const char8_t”[.](#4.sentence-3) The type of a UTF-16 string literal is changed from “array of *some-integer-type*” to “array of const char16_t”[.](#4.sentence-4) The type of a UTF-32 string literal is changed from “array of *some-integer-type*” to “array of const char32_t”[.](#4.sentence-5) The type of a wide string literal is changed from “array of wchar_t” to “array of const wchar_t”[.](#4.sentence-6) **Rationale:** This avoids calling an inappropriate overloaded function, which might expect to be able to modify its argument[.](#4.sentence-7) **Effect on original feature:** Change to semantics of well-defined feature[.](#4.sentence-8) **Difficulty of converting:** Syntactic transformation[.](#4.sentence-9) The fix is to add a cast:char* p = "abc"; // valid in C, invalid in C++void f(char*) {char* p = (char*)"abc"; // OK, cast added f(p); f((char*)"def"); // OK, cast added} **How widely used:** Programs that have a legitimate reason to treat string literal objects as potentially modifiable memory are probably rare[.](#4.sentence-11)