tmp/tmp6lxd6obr/{from.md → to.md}
RENAMED
|
@@ -29,10 +29,16 @@ sizeof('x') == sizeof(int)
|
|
| 29 |
```
|
| 30 |
|
| 31 |
will not work the same as C++ programs. Simple. Programs which depend
|
| 32 |
upon `sizeof('x')` are probably rare.
|
| 33 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
**Change:** String literals made const.
|
| 35 |
The type of a *string-literal* is changed from “array of `char`” to
|
| 36 |
“array of `const char`”. The type of a UTF-8 string literal is changed
|
| 37 |
from “array of `char`” to “array of `const char8_t`”. The type of a
|
| 38 |
UTF-16 string literal is changed from “array of *some-integer-type*” to
|
|
@@ -46,13 +52,13 @@ Change to semantics of well-defined feature. Syntactic transformation.
|
|
| 46 |
The fix is to add a cast:
|
| 47 |
|
| 48 |
``` cpp
|
| 49 |
char* p = "abc"; // valid in C, invalid in C++{}
|
| 50 |
void f(char*) {
|
| 51 |
-
char* p = (char*)"abc"; // OK
|
| 52 |
f(p);
|
| 53 |
-
f((char*)"def"); // OK
|
| 54 |
}
|
| 55 |
```
|
| 56 |
|
| 57 |
Programs that have a legitimate reason to treat string literal objects
|
| 58 |
as potentially modifiable memory are probably rare.
|
|
|
|
| 29 |
```
|
| 30 |
|
| 31 |
will not work the same as C++ programs. Simple. Programs which depend
|
| 32 |
upon `sizeof('x')` are probably rare.
|
| 33 |
|
| 34 |
+
**Change:** Concatenated *string-literal*s can no longer have
|
| 35 |
+
conflicting *encoding-prefix*es. **Rationale:** Removal of non-portable
|
| 36 |
+
feature. **Effect on original feature:** Concatenation of
|
| 37 |
+
*string-literal*s with different *encoding-prefix*es is now ill-formed.
|
| 38 |
+
Syntactic transformation. Seldom.
|
| 39 |
+
|
| 40 |
**Change:** String literals made const.
|
| 41 |
The type of a *string-literal* is changed from “array of `char`” to
|
| 42 |
“array of `const char`”. The type of a UTF-8 string literal is changed
|
| 43 |
from “array of `char`” to “array of `const char8_t`”. The type of a
|
| 44 |
UTF-16 string literal is changed from “array of *some-integer-type*” to
|
|
|
|
| 52 |
The fix is to add a cast:
|
| 53 |
|
| 54 |
``` cpp
|
| 55 |
char* p = "abc"; // valid in C, invalid in C++{}
|
| 56 |
void f(char*) {
|
| 57 |
+
char* p = (char*)"abc"; // OK, cast added
|
| 58 |
f(p);
|
| 59 |
+
f((char*)"def"); // OK, cast added
|
| 60 |
}
|
| 61 |
```
|
| 62 |
|
| 63 |
Programs that have a legitimate reason to treat string literal objects
|
| 64 |
as potentially modifiable memory are probably rare.
|