From Jason Turner

[diff.decl]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp68uqh1td/{from.md → to.md} +0 -70
tmp/tmp68uqh1td/{from.md → to.md} RENAMED
@@ -1,70 +0,0 @@
1
- ### Clause [[dcl.decl]]: declarators <a id="diff.decl">[[diff.decl]]</a>
2
-
3
- [[dcl.fct]] **Change:** In C++, a function declared with an empty
4
- parameter list takes no arguments. In C, an empty parameter list means
5
- that the number and type of the function arguments are unknown.
6
-
7
- Example:
8
-
9
- ``` cpp
10
- int f(); // means int f(void) in C++
11
- // int f( unknown ) in C
12
- ```
13
-
14
- **Rationale:** This is to avoid erroneous function calls (i.e., function
15
- calls with the wrong number or type of arguments). **Effect on original
16
- feature:** Change to semantics of well-defined feature. This feature was
17
- marked as “obsolescent” in C. Syntactic transformation. The function
18
- declarations using C incomplete declaration style must be completed to
19
- become full prototype declarations. A program may need to be updated
20
- 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 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
-