[diff.cpp23.expr] (original) (raw)
Annex C (informative) Compatibility [diff]
C.1 C++ and ISO C++ 2023 [diff.cpp23]
C.1.3 [expr]: expressions [diff.cpp23.expr]
Affected subclause: [expr.arith.conv]
Change: Operations mixing a value of an enumeration type and a value of a different enumeration type or of a floating-point type are no longer valid.
Rationale: Reinforcing type safety.
Effect on original feature: A valid C++ 2023 program that performs operations mixing a value of an enumeration type and a value of a different enumeration type or of a floating-point type is ill-formed.
[Example 1: enum E1 { e };enum E2 { f };bool b = e <= 3.7; int k = f - e; auto x = true ? e : f; — _end example_]
Affected subclauses: [expr.rel] and [expr.eq]
Change: Comparing two objects of array type is no longer valid.
Rationale: The old behavior was confusing since it compared not the contents of the two arrays, but their addresses.
Effect on original feature: A valid C++ 2023 program directly comparing two array objects is rejected as ill-formed in this document.
[Example 2: int arr1[5];int arr2[5];bool same = arr1 == arr2; bool idem = arr1 == +arr2; bool less = arr1 < +arr2; — _end example_]
Affected subclause: [expr.delete]
Change: Calling delete on a pointer to an incomplete class is ill-formed.
Rationale: Reduce undefined behavior.
Effect on original feature: A valid C++ 2023 program that calls delete on an incomplete class type is ill-formed.
[Example 3: struct S;void f(S *p) { delete p; } struct S {}; — _end example_]