From Jason Turner

[diff.expr]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp9mlf9gte/{from.md → to.md} +9 -15
tmp/tmp9mlf9gte/{from.md → to.md} RENAMED
@@ -9,14 +9,14 @@ void* b=a;
9
  void foo() {
10
  char* c=b;
11
  }
12
  ```
13
 
14
- ISO C will accept this usage of pointer to void being assigned to a
15
- pointer to object type. C++ will not. **Rationale:** C++ tries harder
16
  than C to enforce compile-time type safety. **Effect on original
17
- feature:** Deletion of semantically well-defined feature. Could be
18
  automated. Violations will be diagnosed by the C++ translator. The fix
19
  is to add a cast. For example:
20
 
21
  ``` cpp
22
  char* c = (char*) b;
@@ -24,26 +24,20 @@ char* c = (char*) b;
24
 
25
  This is fairly widely used but it is good programming practice to add
26
  the cast when assigning pointer-to-void to pointer-to-object. Some ISO C
27
  translators will give a warning if the cast is not used.
28
 
29
- **Change:** Implicit declaration of functions is not allowed.
30
- **Rationale:** The type-safe nature of C++. **Effect on original
31
- feature:** Deletion of semantically well-defined feature. Note: the
32
- original feature was labeled as “obsolescent” in ISO C. Syntactic
33
- transformation. Facilities for producing explicit function declarations
34
- are fairly widespread commercially. Common.
35
-
36
  **Change:** Decrement operator is not allowed with `bool` operand.
37
  **Rationale:** Feature with surprising semantics. **Effect on original
38
  feature:** A valid ISO C expression utilizing the decrement operator on
39
- a `bool` lvalue (for instance, via the C typedef in ) is ill-formed in
40
- this International Standard.
41
 
42
- **Change:** Types must be defined in declarations, not in expressions.
43
- In C, a sizeof expression or cast expression may define a new type. For
44
- example,
 
45
 
46
  ``` cpp
47
  p = (void*)(struct x {int i;} *)0;
48
  ```
49
 
 
9
  void foo() {
10
  char* c=b;
11
  }
12
  ```
13
 
14
+ ISO C accepts this usage of pointer to `void` being assigned to a
15
+ pointer to object type. C++ does not. **Rationale:** C++ tries harder
16
  than C to enforce compile-time type safety. **Effect on original
17
+ feature:** Deletion of semantically well-defined feature. Can be
18
  automated. Violations will be diagnosed by the C++ translator. The fix
19
  is to add a cast. For example:
20
 
21
  ``` cpp
22
  char* c = (char*) b;
 
24
 
25
  This is fairly widely used but it is good programming practice to add
26
  the cast when assigning pointer-to-void to pointer-to-object. Some ISO C
27
  translators will give a warning if the cast is not used.
28
 
 
 
 
 
 
 
 
29
  **Change:** Decrement operator is not allowed with `bool` operand.
30
  **Rationale:** Feature with surprising semantics. **Effect on original
31
  feature:** A valid ISO C expression utilizing the decrement operator on
32
+ a `bool` lvalue (for instance, via the C typedef in `<stdbool.h>`) is
33
+ ill-formed in C++.
34
 
35
+ **Change:** In C++, types can only be defined in declarations, not in
36
+ expressions.
37
+ In C, a `sizeof` expression or cast expression may define a new type.
38
+ For example,
39
 
40
  ``` cpp
41
  p = (void*)(struct x {int i;} *)0;
42
  ```
43