tmp/tmp7j64gf94/{from.md → to.md}
RENAMED
|
@@ -1,11 +1,11 @@
|
|
| 1 |
### Clause [[dcl.dcl]]: declarations <a id="diff.dcl">[[diff.dcl]]</a>
|
| 2 |
|
| 3 |
[[dcl.stc]] **Change:** In C++, the `static` or `extern` specifiers can
|
| 4 |
-
only be applied to names of objects or functions
|
| 5 |
-
with type declarations is illegal in C++. In C,
|
| 6 |
-
ignored when used on type declarations.
|
| 7 |
|
| 8 |
Example:
|
| 9 |
|
| 10 |
``` cpp
|
| 11 |
static struct S { // valid C, invalid in C++
|
|
@@ -18,57 +18,63 @@ associated with a type. In C++, class members can be declared with the
|
|
| 18 |
`static` storage class specifier. Allowing storage class specifiers on
|
| 19 |
type declarations could render the code confusing for users. **Effect on
|
| 20 |
original feature:** Deletion of semantically well-defined feature.
|
| 21 |
Syntactic transformation. Seldom.
|
| 22 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
[[dcl.typedef]] **Change:** A C++typedef name must be different from any
|
| 24 |
class type name declared in the same scope (except if the typedef is a
|
| 25 |
synonym of the class name with the same name). In C, a typedef name and
|
| 26 |
a struct tag name declared in the same scope can have the same name
|
| 27 |
-
(because they have different name spaces)
|
| 28 |
|
| 29 |
Example:
|
| 30 |
|
| 31 |
``` cpp
|
| 32 |
-
typedef struct name1 {
|
| 33 |
-
struct name {
|
| 34 |
typedef int name; // valid C, invalid C++
|
| 35 |
```
|
| 36 |
|
| 37 |
**Rationale:** For ease of use, C++doesn’t require that a type name be
|
| 38 |
prefixed with the keywords `class`, `struct` or `union` when used in
|
| 39 |
object declarations or type casts.
|
| 40 |
|
| 41 |
Example:
|
| 42 |
|
| 43 |
``` cpp
|
| 44 |
-
class name {
|
| 45 |
name i; // i has type class name
|
| 46 |
```
|
| 47 |
|
| 48 |
**Effect on original feature:** Deletion of semantically well-defined
|
| 49 |
feature. Semantic transformation. One of the 2 types has to be renamed.
|
| 50 |
Seldom.
|
| 51 |
|
| 52 |
-
[[dcl.type]] \[see also [[basic.link]]\] **Change:** const objects
|
| 53 |
-
be initialized in C++but can be left uninitialized in C
|
| 54 |
-
const object cannot be assigned to so it must be
|
| 55 |
-
useful value. **Effect on original feature:**
|
| 56 |
-
well-defined feature. Semantic transformation.
|
|
|
|
| 57 |
|
| 58 |
-
[[dcl.type]] **Change:** Banning implicit int
|
| 59 |
|
| 60 |
In C++a *decl-specifier-seq* must contain a *type-specifier*, unless it
|
| 61 |
is followed by a declarator for a constructor, a destructor, or a
|
| 62 |
conversion function. In the following example, the left-hand column
|
| 63 |
presents valid C; the right-hand column presents equivalent C++:
|
| 64 |
|
| 65 |
``` cpp
|
| 66 |
void f(const parm); void f(const int parm);
|
| 67 |
const n = 3; const int n = 3;
|
| 68 |
main() int main()
|
| 69 |
-
|
| 70 |
```
|
| 71 |
|
| 72 |
**Rationale:** In C++, implicit int creates several opportunities for
|
| 73 |
ambiguity between expressions involving function-like casts and
|
| 74 |
declarations. Explicit declaration is increasingly considered to be
|
|
@@ -92,11 +98,11 @@ variable from its initializer results in undesired interpretations of
|
|
| 92 |
original feature:** Deletion of semantically well-defined feature.
|
| 93 |
Syntactic transformation. Rare.
|
| 94 |
|
| 95 |
[[dcl.enum]] **Change:** C++objects of enumeration type can only be
|
| 96 |
assigned values of the same enumeration type. In C, objects of
|
| 97 |
-
enumeration type can be assigned values of any integral type
|
| 98 |
|
| 99 |
Example:
|
| 100 |
|
| 101 |
``` cpp
|
| 102 |
enum color { red, blue, green };
|
|
|
|
| 1 |
### Clause [[dcl.dcl]]: declarations <a id="diff.dcl">[[diff.dcl]]</a>
|
| 2 |
|
| 3 |
[[dcl.stc]] **Change:** In C++, the `static` or `extern` specifiers can
|
| 4 |
+
only be applied to names of objects or functions.
|
| 5 |
+
Using these specifiers with type declarations is illegal in C++. In C,
|
| 6 |
+
these specifiers are ignored when used on type declarations.
|
| 7 |
|
| 8 |
Example:
|
| 9 |
|
| 10 |
``` cpp
|
| 11 |
static struct S { // valid C, invalid in C++
|
|
|
|
| 18 |
`static` storage class specifier. Allowing storage class specifiers on
|
| 19 |
type declarations could render the code confusing for users. **Effect on
|
| 20 |
original feature:** Deletion of semantically well-defined feature.
|
| 21 |
Syntactic transformation. Seldom.
|
| 22 |
|
| 23 |
+
[[dcl.stc]] **Change:** In C++, `register` is not a storage class
|
| 24 |
+
specifier. **Rationale:** The storage class specifier had no effect in
|
| 25 |
+
C++. **Effect on original feature:** Deletion of semantically
|
| 26 |
+
well-defined feature. Syntactic transformation. Common.
|
| 27 |
+
|
| 28 |
[[dcl.typedef]] **Change:** A C++typedef name must be different from any
|
| 29 |
class type name declared in the same scope (except if the typedef is a
|
| 30 |
synonym of the class name with the same name). In C, a typedef name and
|
| 31 |
a struct tag name declared in the same scope can have the same name
|
| 32 |
+
(because they have different name spaces).
|
| 33 |
|
| 34 |
Example:
|
| 35 |
|
| 36 |
``` cpp
|
| 37 |
+
typedef struct name1 { ... } name1; // valid C and C++
|
| 38 |
+
struct name { ... };
|
| 39 |
typedef int name; // valid C, invalid C++
|
| 40 |
```
|
| 41 |
|
| 42 |
**Rationale:** For ease of use, C++doesn’t require that a type name be
|
| 43 |
prefixed with the keywords `class`, `struct` or `union` when used in
|
| 44 |
object declarations or type casts.
|
| 45 |
|
| 46 |
Example:
|
| 47 |
|
| 48 |
``` cpp
|
| 49 |
+
class name { ... };
|
| 50 |
name i; // i has type class name
|
| 51 |
```
|
| 52 |
|
| 53 |
**Effect on original feature:** Deletion of semantically well-defined
|
| 54 |
feature. Semantic transformation. One of the 2 types has to be renamed.
|
| 55 |
Seldom.
|
| 56 |
|
| 57 |
+
[[dcl.type]] \[see also [[basic.link]]\] **Change:** `const` objects
|
| 58 |
+
must be initialized in C++but can be left uninitialized in C.
|
| 59 |
+
**Rationale:** A const object cannot be assigned to so it must be
|
| 60 |
+
initialized to hold a useful value. **Effect on original feature:**
|
| 61 |
+
Deletion of semantically well-defined feature. Semantic transformation.
|
| 62 |
+
Seldom.
|
| 63 |
|
| 64 |
+
[[dcl.type]] **Change:** Banning implicit `int`.
|
| 65 |
|
| 66 |
In C++a *decl-specifier-seq* must contain a *type-specifier*, unless it
|
| 67 |
is followed by a declarator for a constructor, a destructor, or a
|
| 68 |
conversion function. In the following example, the left-hand column
|
| 69 |
presents valid C; the right-hand column presents equivalent C++:
|
| 70 |
|
| 71 |
``` cpp
|
| 72 |
void f(const parm); void f(const int parm);
|
| 73 |
const n = 3; const int n = 3;
|
| 74 |
main() int main()
|
| 75 |
+
... ...
|
| 76 |
```
|
| 77 |
|
| 78 |
**Rationale:** In C++, implicit int creates several opportunities for
|
| 79 |
ambiguity between expressions involving function-like casts and
|
| 80 |
declarations. Explicit declaration is increasingly considered to be
|
|
|
|
| 98 |
original feature:** Deletion of semantically well-defined feature.
|
| 99 |
Syntactic transformation. Rare.
|
| 100 |
|
| 101 |
[[dcl.enum]] **Change:** C++objects of enumeration type can only be
|
| 102 |
assigned values of the same enumeration type. In C, objects of
|
| 103 |
+
enumeration type can be assigned values of any integral type.
|
| 104 |
|
| 105 |
Example:
|
| 106 |
|
| 107 |
``` cpp
|
| 108 |
enum color { red, blue, green };
|