Affected subclause: [lex.key]
Change: New Keywords
Rationale: These keywords were added in order to implement the new
semantics of C++
. Effect on original feature: Change to semantics of well-defined feature
. Any ISO C programs that used any of these keywords as identifiers
are not valid C++ programs
. Difficulty of converting: Syntactic transformation
. Converting one specific program is easy
. Converting a large collection
of related programs takes more work
. Affected subclause: [lex.ccon]
Rationale: This is needed for improved overloaded function argument type
matching
. For example:
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
. Effect on original feature: Change to semantics of well-defined feature
. ISO C programs which depend on
sizeof('x') == sizeof(int)
will not work the same as C++ programs
. Difficulty of converting: Simple
. How widely used: Programs which depend upon
sizeof('x') are probably rare
. Affected subclause: [lex.string]
Change: String literals made const
.
The type of a
string-literal is changed
from “array of
char”
to “array of
const char”
. The type of a UTF-8 string literal is changed
from “array of
char”
to “array of
const char8_t”
. The type of a UTF-16 string literal is changed
from “array of
some-integer-type”
to “array of
const char16_t”
. The type of a UTF-32 string literal is changed
from “array of
some-integer-type”
to “array of
const char32_t”
. The type of a wide string literal is changed
from “array of
wchar_t”
to “array of
const wchar_t”
. Rationale: This avoids calling an inappropriate overloaded function,
which might expect to be able to modify its argument
. Effect on original feature: Change to semantics of well-defined feature
. Difficulty of converting: Syntactic transformation
. The fix is to add a cast:
char* p = "abc";
void f(char*) {
char* p = (char*)"abc";
f(p);
f((char*)"def");
}
How widely used: Programs that have a legitimate reason to treat string literal objects
as potentially modifiable memory are probably rare
.