tmp/tmpr_0a4s4_/{from.md → to.md}
RENAMED
|
@@ -1,19 +1,18 @@
|
|
| 1 |
-
###
|
| 2 |
|
| 3 |
-
|
| 4 |
-
C.
|
| 5 |
E.g., at file scope,
|
| 6 |
|
| 7 |
``` cpp
|
| 8 |
int i;
|
| 9 |
int i;
|
| 10 |
```
|
| 11 |
|
| 12 |
is valid in C, invalid in C++. This makes it impossible to define
|
| 13 |
-
mutually referential file-local static
|
| 14 |
-
restricted to the syntactic forms of C. For example,
|
| 15 |
|
| 16 |
``` cpp
|
| 17 |
struct X { int i; struct X* next; };
|
| 18 |
|
| 19 |
static struct X a;
|
|
@@ -23,43 +22,42 @@ static struct X a = { 1, &b };
|
|
| 23 |
|
| 24 |
**Rationale:** This avoids having different initialization rules for
|
| 25 |
fundamental types and user-defined types. **Effect on original
|
| 26 |
feature:** Deletion of semantically well-defined feature. Semantic
|
| 27 |
transformation. In C++, the initializer for one of a set of
|
| 28 |
-
mutually-referential file-local
|
| 29 |
-
call to achieve the initialization. Seldom.
|
| 30 |
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
The latter is probably rare.
|
| 38 |
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
explicit initializer for each
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
|
| 55 |
-
|
| 56 |
-
|
| 57 |
For example, otherwise-identical `struct` types with different tag names
|
| 58 |
are “compatible” in C but are distinctly different types in C++.
|
| 59 |
**Rationale:** Stricter type checking is essential for C++. **Effect on
|
| 60 |
original feature:** Deletion of semantically well-defined feature.
|
| 61 |
Semantic transformation. The “typesafe linkage” mechanism will find
|
| 62 |
many, but not all, of such problems. Those problems not found by
|
| 63 |
typesafe linkage will continue to function properly, according to the
|
| 64 |
-
“layout compatibility rules” of this
|
| 65 |
|
|
|
|
| 1 |
+
### [[basic]]: basics <a id="diff.basic">[[diff.basic]]</a>
|
| 2 |
|
| 3 |
+
**Change:** C++ does not have “tentative definitions” as in C.
|
|
|
|
| 4 |
E.g., at file scope,
|
| 5 |
|
| 6 |
``` cpp
|
| 7 |
int i;
|
| 8 |
int i;
|
| 9 |
```
|
| 10 |
|
| 11 |
is valid in C, invalid in C++. This makes it impossible to define
|
| 12 |
+
mutually referential file-local objects with static storage duration, if
|
| 13 |
+
initializers are restricted to the syntactic forms of C. For example,
|
| 14 |
|
| 15 |
``` cpp
|
| 16 |
struct X { int i; struct X* next; };
|
| 17 |
|
| 18 |
static struct X a;
|
|
|
|
| 22 |
|
| 23 |
**Rationale:** This avoids having different initialization rules for
|
| 24 |
fundamental types and user-defined types. **Effect on original
|
| 25 |
feature:** Deletion of semantically well-defined feature. Semantic
|
| 26 |
transformation. In C++, the initializer for one of a set of
|
| 27 |
+
mutually-referential file-local objects with static storage duration
|
| 28 |
+
must invoke a function call to achieve the initialization. Seldom.
|
| 29 |
|
| 30 |
+
**Change:** A `struct` is a scope in C++, not in C. **Rationale:** Class
|
| 31 |
+
scope is crucial to C++, and a struct is a class. **Effect on original
|
| 32 |
+
feature:** Change to semantics of well-defined feature. Semantic
|
| 33 |
+
transformation. C programs use `struct` extremely frequently, but the
|
| 34 |
+
change is only noticeable when `struct`, enumeration, or enumerator
|
| 35 |
+
names are referred to outside the `struct`. The latter is probably rare.
|
|
|
|
| 36 |
|
| 37 |
+
\[also [[dcl.type]]\] **Change:** A name of file scope that is
|
| 38 |
+
explicitly declared `const`, and not explicitly declared `extern`, has
|
| 39 |
+
internal linkage, while in C it would have external linkage.
|
| 40 |
+
**Rationale:** Because const objects may be used as values during
|
| 41 |
+
translation in C++, this feature urges programmers to provide an
|
| 42 |
+
explicit initializer for each const object. This feature allows the user
|
| 43 |
+
to put const objects in source files that are included in more than one
|
| 44 |
+
translation unit. **Effect on original feature:** Change to semantics of
|
| 45 |
+
well-defined feature. Semantic transformation. Seldom.
|
| 46 |
|
| 47 |
+
**Change:** The `main` function cannot be called recursively and cannot
|
| 48 |
+
have its address taken. **Rationale:** The `main` function may require
|
| 49 |
+
special actions. **Effect on original feature:** Deletion of
|
| 50 |
+
semantically well-defined feature. Trivial: create an intermediary
|
| 51 |
+
function such as `mymain(argc, argv)`. Seldom.
|
| 52 |
|
| 53 |
+
**Change:** C allows “compatible types” in several places, C++ does
|
| 54 |
+
not.
|
| 55 |
For example, otherwise-identical `struct` types with different tag names
|
| 56 |
are “compatible” in C but are distinctly different types in C++.
|
| 57 |
**Rationale:** Stricter type checking is essential for C++. **Effect on
|
| 58 |
original feature:** Deletion of semantically well-defined feature.
|
| 59 |
Semantic transformation. The “typesafe linkage” mechanism will find
|
| 60 |
many, but not all, of such problems. Those problems not found by
|
| 61 |
typesafe linkage will continue to function properly, according to the
|
| 62 |
+
“layout compatibility rules” of this document. Common.
|
| 63 |
|