tmp/tmpy66vm9jg/{from.md → to.md}
RENAMED
|
@@ -21,50 +21,50 @@ further if different calls to the same (non-prototype) function have
|
|
| 21 |
different numbers of arguments or if the type of corresponding arguments
|
| 22 |
differed. Common.
|
| 23 |
|
| 24 |
[[dcl.fct]] \[see [[expr.sizeof]]\] **Change:** In C++, types may not be
|
| 25 |
defined in return or parameter types. In C, these type definitions are
|
| 26 |
-
allowed
|
| 27 |
|
| 28 |
Example:
|
| 29 |
|
| 30 |
``` cpp
|
| 31 |
void f( struct S { int a; } arg ) {} // valid C, invalid C++
|
| 32 |
enum E { A, B, C } f() {} // valid C, invalid C++
|
| 33 |
```
|
| 34 |
|
| 35 |
-
**Rationale:** When comparing types in different
|
| 36 |
C++relies on name equivalence when C relies on structural equivalence.
|
| 37 |
-
Regarding parameter types: since the type defined in
|
| 38 |
would be in the scope of the function, the only legal calls in C++ would
|
| 39 |
be from within the function itself. **Effect on original feature:**
|
| 40 |
Deletion of semantically well-defined feature. Semantic transformation.
|
| 41 |
The type definitions must be moved to file scope, or in header files.
|
| 42 |
-
Seldom. This style of type
|
| 43 |
|
| 44 |
[[dcl.fct.def]] **Change:** In C++, the syntax for function definition
|
| 45 |
excludes the “old-style” C function. In C, “old-style” syntax is
|
| 46 |
-
allowed, but deprecated as “obsolescent
|
| 47 |
essential to type safety. **Effect on original feature:** Deletion of
|
| 48 |
semantically well-defined feature. Syntactic transformation. Common in
|
| 49 |
old programs, but already known to be obsolescent.
|
| 50 |
|
| 51 |
[[dcl.init.string]] **Change:** In C++, when initializing an array of
|
| 52 |
character with a string, the number of characters in the string
|
| 53 |
(including the terminating `'\0'`) must not exceed the number of
|
| 54 |
elements in the array. In C, an array can be initialized with a string
|
| 55 |
even if the array is not large enough to contain the string-terminating
|
| 56 |
-
`'\0'`
|
| 57 |
|
| 58 |
Example:
|
| 59 |
|
| 60 |
``` cpp
|
| 61 |
char array[4] = "abcd"; // valid C, invalid C++
|
| 62 |
```
|
| 63 |
|
| 64 |
**Rationale:** When these non-terminated arrays are manipulated by
|
| 65 |
-
standard string
|
| 66 |
**Effect on original feature:** Deletion of semantically well-defined
|
| 67 |
feature. Semantic transformation. The arrays must be declared one
|
| 68 |
element bigger to contain the string terminating `'\0'`. Seldom. This
|
| 69 |
style of array initialization is seen as poor coding style.
|
| 70 |
|
|
|
|
| 21 |
different numbers of arguments or if the type of corresponding arguments
|
| 22 |
differed. Common.
|
| 23 |
|
| 24 |
[[dcl.fct]] \[see [[expr.sizeof]]\] **Change:** In C++, types may not be
|
| 25 |
defined in return or parameter types. In C, these type definitions are
|
| 26 |
+
allowed.
|
| 27 |
|
| 28 |
Example:
|
| 29 |
|
| 30 |
``` cpp
|
| 31 |
void f( struct S { int a; } arg ) {} // valid C, invalid C++
|
| 32 |
enum E { A, B, C } f() {} // valid C, invalid C++
|
| 33 |
```
|
| 34 |
|
| 35 |
+
**Rationale:** When comparing types in different translation units,
|
| 36 |
C++relies on name equivalence when C relies on structural equivalence.
|
| 37 |
+
Regarding parameter types: since the type defined in a parameter list
|
| 38 |
would be in the scope of the function, the only legal calls in C++ would
|
| 39 |
be from within the function itself. **Effect on original feature:**
|
| 40 |
Deletion of semantically well-defined feature. Semantic transformation.
|
| 41 |
The type definitions must be moved to file scope, or in header files.
|
| 42 |
+
Seldom. This style of type definition is seen as poor coding style.
|
| 43 |
|
| 44 |
[[dcl.fct.def]] **Change:** In C++, the syntax for function definition
|
| 45 |
excludes the “old-style” C function. In C, “old-style” syntax is
|
| 46 |
+
allowed, but deprecated as “obsolescent”. **Rationale:** Prototypes are
|
| 47 |
essential to type safety. **Effect on original feature:** Deletion of
|
| 48 |
semantically well-defined feature. Syntactic transformation. Common in
|
| 49 |
old programs, but already known to be obsolescent.
|
| 50 |
|
| 51 |
[[dcl.init.string]] **Change:** In C++, when initializing an array of
|
| 52 |
character with a string, the number of characters in the string
|
| 53 |
(including the terminating `'\0'`) must not exceed the number of
|
| 54 |
elements in the array. In C, an array can be initialized with a string
|
| 55 |
even if the array is not large enough to contain the string-terminating
|
| 56 |
+
`'\0'`.
|
| 57 |
|
| 58 |
Example:
|
| 59 |
|
| 60 |
``` cpp
|
| 61 |
char array[4] = "abcd"; // valid C, invalid C++
|
| 62 |
```
|
| 63 |
|
| 64 |
**Rationale:** When these non-terminated arrays are manipulated by
|
| 65 |
+
standard string functions, there is potential for major catastrophe.
|
| 66 |
**Effect on original feature:** Deletion of semantically well-defined
|
| 67 |
feature. Semantic transformation. The arrays must be declared one
|
| 68 |
element bigger to contain the string terminating `'\0'`. Seldom. This
|
| 69 |
style of array initialization is seen as poor coding style.
|
| 70 |
|