From Jason Turner

[diff.cpp23.expr]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpw4vp4c98/{from.md → to.md} +58 -0
tmp/tmpw4vp4c98/{from.md → to.md} RENAMED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ### [[expr]]: expressions <a id="diff.cpp23.expr">[[diff.cpp23.expr]]</a>
2
+
3
+ **Change:** Operations mixing a value of an enumeration type and a value
4
+ of a different enumeration type or of a floating-point type are no
5
+ longer valid. **Rationale:** Reinforcing type safety. **Effect on
6
+ original feature:** A valid C++23 program that performs operations
7
+ mixing a value of an enumeration type and a value of a different
8
+ enumeration type or of a floating-point type is ill-formed.
9
+
10
+ [*Example 1*:
11
+
12
+ ``` cpp
13
+ enum E1 { e };
14
+ enum E2 { f };
15
+ bool b = e <= 3.7; // ill-formed; previously well-formed
16
+ int k = f - e; // ill-formed; previously well-formed
17
+ auto x = true ? e : f; // ill-formed; previously well-formed
18
+ ```
19
+
20
+ — *end example*]
21
+
22
+ **Change:** Comparing two objects of array type is no longer valid.
23
+ **Rationale:** The old behavior was confusing since it compared not the
24
+ contents of the two arrays, but their addresses. **Effect on original
25
+ feature:** A valid C++23 program directly comparing two array objects is
26
+ rejected as ill-formed in this document.
27
+
28
+ [*Example 2*:
29
+
30
+ ``` cpp
31
+ int arr1[5];
32
+ int arr2[5];
33
+ bool same = arr1 == arr2; // ill-formed; previously well-formed
34
+ bool idem = arr1 == +arr2; // compare addresses
35
+ bool less = arr1 < +arr2; // compare addresses, unspecified result
36
+ ```
37
+
38
+ — *end example*]
39
+
40
+ **Change:** Calling `delete` on a pointer to an incomplete class is
41
+ ill-formed. **Rationale:** Reduce undefined behavior. **Effect on
42
+ original feature:** A valid C++23 program that calls `delete` on an
43
+ incomplete class type is ill-formed.
44
+
45
+ [*Example 3*:
46
+
47
+ ``` cpp
48
+ struct S;
49
+
50
+ void f(S *p) {
51
+ delete p; // ill-formed; previously well-formed
52
+ }
53
+
54
+ struct S {};
55
+ ```
56
+
57
+ — *end example*]
58
+