This commit is contained in:
2025-10-25 03:02:53 +03:00
commit 043225d523
3416 changed files with 681196 additions and 0 deletions

202
cppdraft/diff/basic.md Normal file
View File

@@ -0,0 +1,202 @@
[diff.basic]
# Annex C (informative) Compatibility [[diff]](./#diff)
## C.7 C++ and C [[diff.iso]](diff.iso#diff.basic)
### C.7.3 [[basic]](basic "6Basics"): basics [diff.basic]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L2851)
**Affected subclause:** [[basic.def]](basic.def)
**Change:** C++ does not have “tentative definitions” as in C.
[*Example [1](#example-1)*:
At file scope,int i;int i; is valid in C, invalid in C++[.](#1.sentence-1)
— *end example*]
This makes it impossible to define
mutually referential file-local objects with static storage duration,
if initializers are restricted to the syntactic forms of C[.](#1.sentence-2)
[*Example [2](#example-2)*: struct X { int i; struct X* next; };
static struct X a;static struct X b = { 0, &a };static struct X a = { 1, &b }; — *end example*]
**Rationale:** This avoids having different initialization rules for
fundamental types and user-defined types[.](#1.sentence-3)
**Effect on original feature:** Deletion of semantically well-defined feature[.](#1.sentence-4)
**Difficulty of converting:** Semantic transformation[.](#1.sentence-5)
In C++, the initializer for one of a set of
mutually-referential file-local objects with static storage
duration must invoke a function
call to achieve the initialization[.](#1.sentence-6)
**How widely used:** Seldom[.](#1.sentence-7)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L2888)
**Affected subclause:** [[basic.scope]](basic.scope)
**Change:** A struct is a scope in C++, not in C.
[*Example [3](#example-3)*:
struct X {struct Y { int a; } b;};struct Y c; is valid in C but not in C++, which would require X::Y c;[.](#2.sentence-1)
— *end example*]
**Rationale:** Class scope is crucial to C++, and a struct is a class[.](#2.sentence-3)
**Effect on original feature:** Change to semantics of well-defined feature[.](#2.sentence-4)
**Difficulty of converting:** Semantic transformation[.](#2.sentence-5)
**How widely used:** C programs use struct extremely frequently, but the
change is only noticeable when struct, enumeration, or enumerator
names are referred to outside the struct[.](#2.sentence-6)
The latter is probably rare[.](#2.sentence-7)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L2912)
**Affected subclause:** [[basic.link]](basic.link) [also [[dcl.type]](dcl.type "9.2.9Type specifiers")]
**Change:** A name of file scope that is explicitly declared const, and not explicitly
declared extern, has internal linkage, while in C it would have external linkage[.](#3.sentence-2)
**Rationale:** Because const objects may be used as values during translation in
C++, this feature urges programmers to provide an explicit initializer
for each const object[.](#3.sentence-3)
This feature allows the user to put const objects in source files that are included
in more than one translation unit[.](#3.sentence-4)
**Effect on original feature:** Change to semantics of well-defined feature[.](#3.sentence-5)
**Difficulty of converting:** Semantic transformation[.](#3.sentence-6)
**How widely used:** Seldom[.](#3.sentence-7)
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L2929)
**Affected subclause:** [[basic.start.main]](basic.start.main)
**Change:** The main function cannot be called recursively and cannot have its address taken[.](#4.sentence-1)
**Rationale:** The main function may require special actions[.](#4.sentence-2)
**Effect on original feature:** Deletion of semantically well-defined feature[.](#4.sentence-3)
**Difficulty of converting:** Trivial: create an intermediary function such asmymain(argc, argv)[.](#4.sentence-4)
**How widely used:** Seldom[.](#4.sentence-5)
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L2942)
**Affected subclause:** [[basic.types]](basic.types)
**Change:** C allows “compatible types” in several places, C++ does not[.](#5.sentence-1)
For example,
otherwise-identical struct types with different tag names
are “compatible” in C but are distinctly different types
in C++[.](#5.sentence-2)
**Rationale:** Stricter type checking is essential for C++[.](#5.sentence-3)
**Effect on original feature:** Deletion of semantically well-defined feature[.](#5.sentence-4)
**Difficulty of converting:** Semantic transformation[.](#5.sentence-5)
The “typesafe linkage” mechanism will find many, but not all,
of such problems[.](#5.sentence-6)
Those problems not found by typesafe linkage will continue to
function properly,
according to the “layout compatibility rules” of this
document[.](#5.sentence-7)
**How widely used:** Common[.](#5.sentence-8)

19
cppdraft/diff/char16.md Normal file
View File

@@ -0,0 +1,19 @@
[diff.char16]
# Annex C (informative) Compatibility [[diff]](./#diff)
## C.8 C standard library [[diff.library]](diff.library#diff.char16)
### C.8.3 Modifications to definitions [[diff.mods.to.definitions]](diff.mods.to.definitions#diff.char16)
#### C.8.3.1 Types char8_t, char16_t, and char32_t [diff.char16]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L3711)
The types char8_t, char16_t, and char32_t are distinct types rather than typedefs to existing integral types[.](#1.sentence-1)
The tokens char8_t, char16_t, and char32_t are keywords in C++ ([[lex.key]](lex.key "5.12Keywords"))[.](#1.sentence-2)
They do not appear as macro or type names defined in[<cuchar>](cuchar.syn#header:%3ccuchar%3e "28.7.4Header <cuchar> synopsis[cuchar.syn]")[.](#1.sentence-3)

244
cppdraft/diff/class.md Normal file
View File

@@ -0,0 +1,244 @@
[diff.class]
# Annex C (informative) Compatibility [[diff]](./#diff)
## C.7 C++ and C [[diff.iso]](diff.iso#diff.class)
### C.7.7 [[class]](class "11Classes"): classes [diff.class]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L3483)
**Affected subclause:** [[class.name]](class.name) [see also [[dcl.typedef]](dcl.typedef "9.2.4The typedef specifier")]
**Change:** In C++, a class declaration introduces the class name into the scope where it is
declared and hides any object, function or other declaration of that name in an enclosing
scope[.](#1.sentence-2)
In C, an inner scope declaration of a struct tag name never hides the name of an
object or function in an outer scope[.](#1.sentence-3)
[*Example [1](#example-1)*: int x[99];void f() {struct x { int a; }; sizeof(x); /* size of the array in C *//* size of the struct in *C++* */} — *end example*]
**Rationale:** This is one of the few incompatibilities between C and C++ that
can be attributed to the new C++ name space definition where a
name can be declared as a type and as a non-type in a single scope
causing the non-type name to hide the type name and requiring that
the keywords class, struct, union or enum be used to refer to the type name[.](#1.sentence-4)
This new name space definition provides important notational
conveniences to C++ programmers and helps making the use of the
user-defined types as similar as possible to the use of fundamental
types[.](#1.sentence-5)
The advantages of the new name space definition were judged to
outweigh by far the incompatibility with C described above[.](#1.sentence-6)
**Effect on original feature:** Change to semantics of well-defined feature[.](#1.sentence-7)
**Difficulty of converting:** Semantic transformation[.](#1.sentence-8)
If the hidden name that needs to be accessed is at global scope,
the :: C++ operator can be used[.](#1.sentence-9)
If the hidden name is at block scope, either the type or the struct
tag has to be renamed[.](#1.sentence-10)
**How widely used:** Seldom[.](#1.sentence-11)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L3523)
**Affected subclause:** [[class.copy.ctor]](class.copy.ctor)
**Change:** Copying volatile objects[.](#2.sentence-1)
The implicitly-declared copy constructor and
implicitly-declared copy assignment operator
cannot make a copy of a volatile lvalue[.](#2.sentence-2)
[*Example [2](#example-2)*:
The following is valid in C:struct X { int i; };volatile struct X x1 = {0};struct X x2 = x1; // invalid C++struct X x3;
x3 = x1; // also invalid C++
— *end example*]
**Rationale:** Several alternatives were debated at length[.](#2.sentence-4)
Changing the parameter tovolatileconstX& would greatly complicate the generation of
efficient code for class objects[.](#2.sentence-5)
Discussion of
providing two alternative signatures for these
implicitly-defined operations raised
unanswered concerns about creating
ambiguities and complicating
the rules that specify the formation of
these operators according to the bases and
members[.](#2.sentence-6)
**Effect on original feature:** Deletion of semantically well-defined feature[.](#2.sentence-7)
**Difficulty of converting:** Semantic transformation[.](#2.sentence-8)
If volatile semantics are required for the copy,
a user-declared constructor or assignment must
be provided[.](#2.sentence-9)
If non-volatile semantics are required,
an explicitconst_cast can be used[.](#2.sentence-10)
**How widely used:** Seldom[.](#2.sentence-11)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L3571)
**Affected subclause:** [[class.bit]](class.bit)
**Change:** Bit-fields of type plain int are signed[.](#3.sentence-1)
**Rationale:** The signedness needs to be consistent among template specializations[.](#3.sentence-2)
For consistency,
the implementation freedom was eliminated for non-dependent types,
too[.](#3.sentence-3)
**Effect on original feature:** The choice is implementation-defined in C, but not so in C++[.](#3.sentence-4)
**Difficulty of converting:** Syntactic transformation[.](#3.sentence-5)
**How widely used:** Seldom[.](#3.sentence-6)
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L3587)
**Affected subclause:** [[class.nest]](class.nest)
**Change:** In C++, the name of a nested class is local to its enclosing class[.](#4.sentence-1)
In C
the name of the nested class belongs to the same scope as the name of the outermost enclosing class[.](#4.sentence-2)
[*Example [3](#example-3)*: struct X {struct Y { /* ... */ } y;};struct Y yy; // valid C, invalid C++ — *end example*]
**Rationale:** C++ classes have member functions which require that classes
establish scopes[.](#4.sentence-3)
The C rule would leave classes as an incomplete scope mechanism
which would prevent C++ programmers from maintaining locality
within a class[.](#4.sentence-4)
A coherent set of scope rules for C++ based on the C rule would
be very complicated and C++ programmers would be unable to predict
reliably the meanings of nontrivial examples involving nested or
local functions[.](#4.sentence-5)
**Effect on original feature:** Change to semantics of well-defined feature[.](#4.sentence-6)
**Difficulty of converting:** Semantic transformation[.](#4.sentence-7)
To make the struct type name visible in the scope of the enclosing
struct, the struct tag can be declared in the scope of the
enclosing struct, before the enclosing struct is defined[.](#4.sentence-8)
[*Example [4](#example-4)*: struct Y; // struct Y and struct X are at the same scopestruct X {struct Y { /* ... */ } y;}; — *end example*]
All the definitions of C struct types enclosed in other struct
definitions and accessed outside the scope of the enclosing
struct can be exported to the scope of the enclosing struct[.](#4.sentence-9)
Note: this is a consequence of the difference in scope rules,
which is documented in [[basic.scope]](basic.scope "6.4Scope")[.](#4.sentence-10)
**How widely used:** Seldom[.](#4.sentence-11)
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L3634)
**Affected subclause:** [[class.member.lookup]](class.member.lookup)
**Change:** In C++, a [*typedef-name*](dcl.typedef#nt:typedef-name "9.2.4The typedef specifier[dcl.typedef]") may not be redeclared in a class definition after being used in that definition[.](#5.sentence-1)
[*Example [5](#example-5)*: typedef int I;struct S { I i; int I; // valid C, invalid C++}; — *end example*]
**Rationale:** When classes become complicated, allowing such a redefinition
after the type has been used can create confusion for C++
programmers as to what the meaning of I really is[.](#5.sentence-2)
**Effect on original feature:** Deletion of semantically well-defined feature[.](#5.sentence-3)
**Difficulty of converting:** Semantic transformation[.](#5.sentence-4)
Either the type or the struct member has to be renamed[.](#5.sentence-5)
**How widely used:** Seldom[.](#5.sentence-6)

39
cppdraft/diff/cpp.md Normal file
View File

@@ -0,0 +1,39 @@
[diff.cpp]
# Annex C (informative) Compatibility [[diff]](./#diff)
## C.7 C++ and C [[diff.iso]](diff.iso#diff.cpp)
### C.7.8 [[cpp]](cpp "15Preprocessing directives"): preprocessing directives [diff.cpp]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L3661)
**Affected subclause:** [[cpp.predefined]](cpp.predefined)
**Change:** Whether __STDC__ is defined and if so, what its value is, areimplementation-defined[.](#1.sentence-1)
**Rationale:** C++ is not identical to C[.](#1.sentence-2)
Mandating that __STDC__ be defined would require that translators make an incorrect claim[.](#1.sentence-3)
**Effect on original feature:** Change to semantics of well-defined feature[.](#1.sentence-4)
**Difficulty of converting:** Semantic transformation[.](#1.sentence-5)
**How widely used:** Programs and headers that reference __STDC__ are
quite common[.](#1.sentence-6)

1016
cppdraft/diff/cpp03.md Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,31 @@
[diff.cpp03.algorithms]
# Annex C (informative) Compatibility [[diff]](./#diff)
## C.6 C++ and ISO C++ 2003 [[diff.cpp03]](diff.cpp03#algorithms)
### C.6.13 [[algorithms]](algorithms "26Algorithms library"): algorithms library [diff.cpp03.algorithms]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L2648)
**Affected subclause:** [[algorithms.general]](algorithms.general)
**Change:** Result state of inputs after application of some algorithms[.](#1.sentence-1)
**Rationale:** Required by new feature[.](#1.sentence-2)
**Effect on original feature:** A valid C++ 2003 program may detect that an object with a valid but
unspecified state has a different valid but unspecified state with this
revision of C++[.](#1.sentence-3)
For example, std::remove andstd::remove_if may leave the tail of the input sequence with a
different set of values than previously[.](#1.sentence-4)

View File

@@ -0,0 +1,52 @@
[diff.cpp03.class]
# Annex C (informative) Compatibility [[diff]](./#diff)
## C.6 C++ and ISO C++ 2003 [[diff.cpp03]](diff.cpp03#class)
### C.6.5 [[class]](class "11Classes"): classes [diff.cpp03.class]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L2345)
**Affected subclauses:** [[class.default.ctor]](class.default.ctor), [[class.dtor]](class.dtor), [[class.copy.ctor]](class.copy.ctor), and [[class.copy.assign]](class.copy.assign)
**Change:** Implicitly-declared special member functions are defined as deleted
when the implicit definition would have been ill-formed[.](#1.sentence-1)
**Rationale:** Improves template argument deduction failure[.](#1.sentence-2)
**Effect on original feature:** A valid C++ 2003 program that uses one of these special member functions in a
context where the definition is not required (e.g., in an expression that is
not potentially evaluated) becomes ill-formed[.](#1.sentence-3)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L2356)
**Affected subclause:** [[class.dtor]](class.dtor)
**Change:** User-declared destructors have an implicit exception specification[.](#2.sentence-1)
**Rationale:** Clarification of destructor requirements[.](#2.sentence-2)
**Effect on original feature:** Valid C++ 2003 code may execute differently in this revision of C++[.](#2.sentence-3)
In
particular, destructors that throw exceptions will call std::terminate (without calling std::unexpected) if their exception specification is
non-throwing[.](#2.sentence-4)

View File

@@ -0,0 +1,192 @@
[diff.cpp03.containers]
# Annex C (informative) Compatibility [[diff]](./#diff)
## C.6 C++ and ISO C++ 2003 [[diff.cpp03]](diff.cpp03#containers)
### C.6.12 [[containers]](containers "23Containers library"): containers library [diff.cpp03.containers]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L2557)
**Affected subclause:** [[container.requirements]](container.requirements)
**Change:** Complexity of size() member functions now constant[.](#1.sentence-1)
**Rationale:** Lack of specification of complexity of size() resulted in
divergent implementations with inconsistent performance characteristics[.](#1.sentence-2)
**Effect on original feature:** Some container implementations that conform to C++ 2003 may not conform to the
specified size() requirements in this revision of C++[.](#1.sentence-3)
Adjusting
containers such as std::list to the stricter requirements may require
incompatible changes[.](#1.sentence-4)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L2569)
**Affected subclause:** [[container.requirements]](container.requirements)
**Change:** Requirements change: relaxation[.](#2.sentence-1)
**Rationale:** Clarification[.](#2.sentence-2)
**Effect on original feature:** Valid C++ 2003 code that attempts to meet the specified container requirements
may now be over-specified[.](#2.sentence-3)
Code that attempted to be portable across containers
may need to be adjusted as follows:
- [(2.1)](#2.1)
not all containers provide size(); use empty() instead
of size() == 0;
- [(2.2)](#2.2)
not all containers are empty after construction (array);
- [(2.3)](#2.3)
not all containers have constant complexity for swap() (array)[.](#2.sentence-4)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L2585)
**Affected subclause:** [[container.requirements]](container.requirements)
**Change:** Requirements change: default constructible[.](#3.sentence-1)
**Rationale:** Clarification of container requirements[.](#3.sentence-2)
**Effect on original feature:** Valid C++ 2003 code that attempts to explicitly instantiate a container using
a user-defined type with no default constructor may fail to compile[.](#3.sentence-3)
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L2594)
**Affected subclauses:** [[sequence.reqmts]](sequence.reqmts) and [[associative.reqmts]](associative.reqmts)
**Change:** Signature changes: from void return types[.](#4.sentence-1)
**Rationale:** Old signature threw away useful information that may be expensive
to recalculate[.](#4.sentence-2)
**Effect on original feature:** The following member functions have changed:
- [(4.1)](#4.1)
erase(iter) for set, multiset, map, multimap
- [(4.2)](#4.2)
erase(begin, end) for set, multiset, map, multimap
- [(4.3)](#4.3)
insert(pos, num, val) for vector, deque, list, forward_list
- [(4.4)](#4.4)
insert(pos, beg, end) for vector, deque, list, forward_list
Valid C++ 2003 code that relies on these functions returning void (e.g., code that creates a pointer to member function that points to one
of these functions) will fail to compile with this revision of C++[.](#4.sentence-4)
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L2613)
**Affected subclauses:** [[sequence.reqmts]](sequence.reqmts) and [[associative.reqmts]](associative.reqmts)
**Change:** Signature changes: from iterator to const_iterator parameters[.](#5.sentence-1)
**Rationale:** Overspecification[.](#5.sentence-2)
**Effect on original feature:** The signatures of the following member functions changed from taking aniterator to taking a const_iterator:
- [(5.1)](#5.1)
insert(iter, val) for vector, deque, list,set, multiset, map, multimap
- [(5.2)](#5.2)
insert(pos, beg, end) for vector, deque, list,forward_list
- [(5.3)](#5.3)
erase(begin, end) for set, multiset, map, multimap
- [(5.4)](#5.4)
all forms of list::splice
- [(5.5)](#5.5)
all forms of list::merge
Valid C++ 2003 code that uses these functions may fail to compile with this
revision of C++[.](#5.sentence-4)
[6](#6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L2635)
**Affected subclauses:** [[sequence.reqmts]](sequence.reqmts) and [[associative.reqmts]](associative.reqmts)
**Change:** Signature changes: resize[.](#6.sentence-1)
**Rationale:** Performance, compatibility with move semantics[.](#6.sentence-2)
**Effect on original feature:** For vector, deque, and list the fill value passed to resize is now passed by reference instead of
by value, and an additional overload of resize has been added[.](#6.sentence-3)
Valid
C++ 2003 code that uses this function may fail to compile with this revision of C++[.](#6.sentence-4)

View File

@@ -0,0 +1,87 @@
[diff.cpp03.dcl.dcl]
# Annex C (informative) Compatibility [[diff]](./#diff)
## C.6 C++ and ISO C++ 2003 [[diff.cpp03]](diff.cpp03#dcl.dcl)
### C.6.4 [[dcl]](dcl "9Declarations"): declarations [diff.cpp03.dcl.dcl]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L2292)
**Affected subclause:** [[dcl.spec]](dcl.spec)
**Change:** Remove auto as a storage class specifier[.](#1.sentence-1)
**Rationale:** New feature[.](#1.sentence-2)
**Effect on original feature:** Valid C++ 2003 code that uses the keyword auto as a storage class
specifier
may be invalid in this revision of C++[.](#1.sentence-3)
In this revision of C++,auto indicates that the type of a variable is to be deduced
from its initializer expression[.](#1.sentence-4)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L2305)
**Affected subclause:** [[dcl.init.list]](dcl.init.list)
**Change:** Narrowing restrictions in aggregate initializers[.](#2.sentence-1)
**Rationale:** Catches bugs[.](#2.sentence-2)
**Effect on original feature:** Valid C++ 2003 code may fail to compile in this revision of C++[.](#2.sentence-3)
[*Example [1](#example-1)*: int x[] = { 2.0 };
This code is valid in C++ 2003 but invalid in this
revision of C++ because double to int is a narrowing
conversion[.](#2.sentence-4)
— *end example*]
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L2321)
**Affected subclause:** [[dcl.link]](dcl.link)
**Change:** Names declared in an anonymous namespace
changed from external linkage to internal linkage;
language linkage applies to names with external linkage only[.](#3.sentence-1)
**Rationale:** Alignment with user expectations[.](#3.sentence-2)
**Effect on original feature:** Valid C++ 2003 code may violate the one-definition rule ([[basic.def.odr]](basic.def.odr "6.3One-definition rule"))
in this revision of C++[.](#3.sentence-3)
[*Example [2](#example-2)*: namespace { extern "C" { extern int x; } } // #1, previously external linkage and C language linkage,// now internal linkage and C++ language linkagenamespace A { extern "C" int x = 42; } // #2, external linkage and C language linkageint main(void) { return x; }
This code is valid in C++ 2003,
but #2 is not a definition for #1 in this revision of C++, violating the one-definition rule[.](#3.sentence-4)
— *end example*]

View File

@@ -0,0 +1,27 @@
[diff.cpp03.diagnostics]
# Annex C (informative) Compatibility [[diff]](./#diff)
## C.6 C++ and ISO C++ 2003 [[diff.cpp03]](diff.cpp03#diagnostics)
### C.6.9 [[diagnostics]](diagnostics "19Diagnostics library"): diagnostics library [diff.cpp03.diagnostics]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L2509)
**Affected subclause:** [[errno]](errno)
**Change:** Thread-local error numbers[.](#1.sentence-1)
**Rationale:** Support for new thread facilities[.](#1.sentence-2)
**Effect on original feature:** Valid but implementation-specific C++ 2003 code that relies onerrno being the same across threads may change behavior in this
revision of C++[.](#1.sentence-3)

116
cppdraft/diff/cpp03/expr.md Normal file
View File

@@ -0,0 +1,116 @@
[diff.cpp03.expr]
# Annex C (informative) Compatibility [[diff]](./#diff)
## C.6 C++ and ISO C++ 2003 [[diff.cpp03]](diff.cpp03#expr)
### C.6.3 [[expr]](expr "7Expressions"): expressions [diff.cpp03.expr]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L2198)
**Affected subclause:** [[conv.ptr]](conv.ptr)
**Change:** Only literals are integer null pointer constants[.](#1.sentence-1)
**Rationale:** Removing surprising interactions with templates and constant
expressions[.](#1.sentence-2)
**Effect on original feature:** Valid C++ 2003 code may fail to compile or produce different results in
this revision of C++[.](#1.sentence-3)
[*Example [1](#example-1)*: void f(void *); // #1void f(...); // #2template<int N> void g() { f(0*N); // calls #2; used to call #1} — *end example*]
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L2217)
**Affected subclause:** [[expr.typeid]](expr.typeid)
**Change:** Evaluation of operands in typeid[.](#2.sentence-1)
**Rationale:** Introduce additional expression value categories[.](#2.sentence-2)
**Effect on original feature:** Valid C++ 2003 code that uses xvalues as operands for typeid may change behavior in this revision of C++[.](#2.sentence-3)
[*Example [2](#example-2)*: void f() {struct B { B() {}virtual ~B() { }}; struct C { B b; }; typeid(C().b); // unevaluated in C++ 2003, evaluated in C++ 2011} — *end example*]
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L2239)
**Affected subclause:** [[expr.mul]](expr.mul)
**Change:** Specify rounding for results of integer / and %[.](#3.sentence-1)
**Rationale:** Increase portability, C99 compatibility[.](#3.sentence-2)
**Effect on original feature:** Valid C++ 2003 code that uses integer division rounds the result toward 0 or
toward negative infinity, whereas this revision of C++ always rounds
the result toward 0[.](#3.sentence-3)
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L2249)
**Affected subclause:** [[expr.log.and]](expr.log.and)
**Change:** && is valid in a [*type-name*](dcl.type.simple#nt:type-name "9.2.9.3Simple type specifiers[dcl.type.simple]")[.](#4.sentence-1)
**Rationale:** Required for new features[.](#4.sentence-2)
**Effect on original feature:** Valid C++ 2003 code may fail to compile or produce different results in
this revision of C++[.](#4.sentence-3)
[*Example [3](#example-3)*: bool b1 = new int && false; // previously false, now ill-formedstruct S { operator int(); };bool b2 = &S::operator int && false; // previously false, now ill-formed — *end example*]
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L2265)
**Affected subclause:** [[expr.cond]](expr.cond)
**Change:** Fewer copies in the conditional operator[.](#5.sentence-1)
**Rationale:** Introduce additional expression value categories[.](#5.sentence-2)
**Effect on original feature:** Valid C++ 2003 code that uses xvalues as operands for the conditional operator
may change behavior in this revision of C++[.](#5.sentence-3)
[*Example [4](#example-4)*: void f() {struct B { B() {} B(const B&) { }}; struct D : B {}; struct BB { B b; }; struct DD { D d; }; true ? BB().b : DD().d; // additional copy in C++ 2003, no copy or move in C++ 2011} — *end example*]

View File

@@ -0,0 +1,16 @@
[diff.cpp03.general]
# Annex C (informative) Compatibility [[diff]](./#diff)
## C.6 C++ and ISO C++ 2003 [[diff.cpp03]](diff.cpp03#general)
### C.6.1 General [diff.cpp03.general]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L2121)
Subclause [[diff.cpp03]](diff.cpp03 "C.6C++ and ISO C++ 2003") lists the differences between C++ and
ISO C++ 2003,
in addition to those listed above,
by the chapters of this document[.](#1.sentence-1)

View File

@@ -0,0 +1,98 @@
[diff.cpp03.input.output]
# Annex C (informative) Compatibility [[diff]](./#diff)
## C.6 C++ and ISO C++ 2003 [[diff.cpp03]](diff.cpp03#input.output)
### C.6.16 [[input.output]](input.output "31Input/output library"): input/output library [diff.cpp03.input.output]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L2684)
**Affected subclauses:** [[istream.sentry]](istream.sentry), [[ostream.sentry]](ostream.sentry), and [[iostate.flags]](iostate.flags)
**Change:** Specify use of explicit in existing boolean conversion functions[.](#1.sentence-1)
**Rationale:** Clarify intentions, avoid workarounds[.](#1.sentence-2)
**Effect on original feature:** Valid C++ 2003 code that relies on implicit boolean conversions will fail to
compile with this revision of C++[.](#1.sentence-3)
Such conversions occur in the
following conditions:
- [(1.1)](#1.1)
passing a value to a function that takes an argument of type bool;
- [(1.2)](#1.2)
using operator== to compare to false or true;
- [(1.3)](#1.3)
returning a value from a function with a return type of bool;
- [(1.4)](#1.4)
initializing members of type bool via aggregate initialization;
- [(1.5)](#1.5)
initializing a const bool& which would bind to a temporary object[.](#1.sentence-4)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L2701)
**Affected subclause:** [[ios.failure]](ios.failure)
**Change:** Change base class of std::ios_base::failure[.](#2.sentence-1)
**Rationale:** More detailed error messages[.](#2.sentence-2)
**Effect on original feature:** std::ios_base::failure is no longer derived directly fromstd::exception, but is now derived from std::system_error,
which in turn is derived from std::runtime_error[.](#2.sentence-3)
Valid C++ 2003 code
that assumes that std::ios_base::failure is derived directly fromstd::exception may execute differently in this revision of C++[.](#2.sentence-4)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L2713)
**Affected subclause:** [[ios.base]](ios.base)
**Change:** Flag types in std::ios_base are now bitmasks with values
defined as constexpr static members[.](#3.sentence-1)
**Rationale:** Required for new features[.](#3.sentence-2)
**Effect on original feature:** Valid C++ 2003 code that relies on std::ios_base flag types being
represented as std::bitset or as an integer type may fail to compile
with this revision of C++[.](#3.sentence-3)
[*Example [1](#example-1)*: #include <iostream>int main() {int flag = std::ios_base::hex;
std::cout.setf(flag); // error: setf does not take argument of type int} — *end example*]

View File

@@ -0,0 +1,31 @@
[diff.cpp03.language.support]
# Annex C (informative) Compatibility [[diff]](./#diff)
## C.6 C++ and ISO C++ 2003 [[diff.cpp03]](diff.cpp03#language.support)
### C.6.8 [[support]](support "17Language support library"):
language support library [diff.cpp03.language.support]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L2493)
**Affected subclause:** [[new.delete.single]](new.delete.single)
**Change:** operator new may throw exceptions other thanstd::bad_alloc[.](#1.sentence-1)
**Rationale:** Consistent application of noexcept[.](#1.sentence-2)
**Effect on original feature:** Valid C++ 2003 code that assumes that global operator new only
throws std::bad_alloc may execute differently in this revision of C++[.](#1.sentence-3)
Valid C++ 2003 code that replaces the global replaceable operator new is ill-formed in this revision of C++,
because the exception specification of throw(std::bad_alloc) was removed[.](#1.sentence-4)

105
cppdraft/diff/cpp03/lex.md Normal file
View File

@@ -0,0 +1,105 @@
[diff.cpp03.lex]
# Annex C (informative) Compatibility [[diff]](./#diff)
## C.6 C++ and ISO C++ 2003 [[diff.cpp03]](diff.cpp03#lex)
### C.6.2 [[lex]](lex "5Lexical conventions"): lexical conventions [diff.cpp03.lex]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L2130)
**Affected subclause:** [[lex.pptoken]](lex.pptoken)
**Change:** New kinds of [*string-literal*](lex.string#nt:string-literal "5.13.5String literals[lex.string]")*s*[.](#1.sentence-1)
**Rationale:** Required for new features[.](#1.sentence-2)
**Effect on original feature:** Valid C++ 2003 code may fail to compile or produce different results in
this revision of C++[.](#1.sentence-3)
Specifically, macros named R, u8,u8R, u, uR, U, UR, or LR will
not be expanded when adjacent to a [*string-literal*](lex.string#nt:string-literal "5.13.5String literals[lex.string]") but will be interpreted as
part of the [*string-literal*](lex.string#nt:string-literal "5.13.5String literals[lex.string]")[.](#1.sentence-4)
[*Example [1](#example-1)*: #define u8 "abc"const char* s = u8"def"; // Previously "abcdef", now "def" — *end example*]
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L2148)
**Affected subclause:** [[lex.pptoken]](lex.pptoken)
**Change:** User-defined literal string support[.](#2.sentence-1)
**Rationale:** Required for new features[.](#2.sentence-2)
**Effect on original feature:** Valid C++ 2003 code may fail to compile or produce different results in
this revision of C++[.](#2.sentence-3)
[*Example [2](#example-2)*: #define _x "there""hello"_x // #1
Previously, #1 would have consisted of two separate preprocessing tokens and
the macro _x would have been expanded[.](#2.sentence-4)
In this revision of C++,
#1 consists of a single preprocessing token, so the macro is not expanded[.](#2.sentence-5)
— *end example*]
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L2167)
**Affected subclause:** [[lex.key]](lex.key)
**Change:** New keywords[.](#3.sentence-1)
**Rationale:** Required for new features[.](#3.sentence-2)
**Effect on original feature:** Added to Table [5](lex.key#tab:lex.key "Table 5: Keywords"), the following identifiers are new keywords:alignas,alignof,char16_t,char32_t,constexpr,decltype,noexcept,nullptr,static_assert,
andthread_local[.](#3.sentence-3)
Valid C++ 2003 code using these identifiers is invalid in this revision of C++[.](#3.sentence-4)
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L2187)
**Affected subclause:** [[lex.icon]](lex.icon)
**Change:** Type of integer literals[.](#4.sentence-1)
**Rationale:** C99 compatibility[.](#4.sentence-2)
**Effect on original feature:** Certain integer literals larger than can be represented by long could
change from an unsigned integer type to signed long long[.](#4.sentence-3)

View File

@@ -0,0 +1,122 @@
[diff.cpp03.library]
# Annex C (informative) Compatibility [[diff]](./#diff)
## C.6 C++ and ISO C++ 2003 [[diff.cpp03]](diff.cpp03#library)
### C.6.7 [[library]](library "16Library introduction"): library introduction [diff.cpp03.library]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L2411)
**Affected:** [[library]](library "16Library introduction") – [[exec]](exec "33Execution control library")
**Change:** New reserved identifiers[.](#1.sentence-2)
**Rationale:** Required by new features[.](#1.sentence-3)
**Effect on original feature:** Valid C++ 2003 code that uses any identifiers added to the C++ standard
library by later revisions of C++ may fail to compile or produce different
results in this revision of C++[.](#1.sentence-4)
A comprehensive list of identifiers used
by the C++ standard library can be found in the Index of Library Names in this
document[.](#1.sentence-5)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L2424)
**Affected subclause:** [[headers]](headers)
**Change:** New headers[.](#2.sentence-1)
**Rationale:** New functionality[.](#2.sentence-2)
**Effect on original feature:** The following C++ headers are new:[<array>](array.syn#header:%3carray%3e "23.3.2Header <array> synopsis[array.syn]"),[<atomic>](atomics.syn#header:%3catomic%3e "32.5.2Header <atomic> synopsis[atomics.syn]"),[<chrono>](time.syn#header:%3cchrono%3e "30.2Header <chrono> synopsis[time.syn]"),[<condition_variable>](condition.variable.syn#header:%3ccondition_variable%3e "32.7.2Header <condition_­variable> synopsis[condition.variable.syn]"),[<forward_list>](forward.list.syn#header:%3cforward_list%3e "23.3.6Header <forward_­list> synopsis[forward.list.syn]"),[<future>](future.syn#header:%3cfuture%3e "32.10.2Header <future> synopsis[future.syn]"),<initializer_list> ([[initializer.list.syn]](initializer.list.syn "17.11.2Header <initializer_­list> synopsis")),[<mutex>](mutex.syn#header:%3cmutex%3e "32.6.2Header <mutex> synopsis[mutex.syn]"),[<random>](rand.synopsis#header:%3crandom%3e "29.5.2Header <random> synopsis[rand.synopsis]"),[<ratio>](ratio.syn#header:%3cratio%3e "21.5.2Header <ratio> synopsis[ratio.syn]"),[<regex>](re.syn#header:%3cregex%3e "28.6.3Header <regex> synopsis[re.syn]"),[<scoped_allocator>](allocator.adaptor.syn#header:%3cscoped_allocator%3e "20.6.1Header <scoped_­allocator> synopsis[allocator.adaptor.syn]"),[<system_error>](system.error.syn#header:%3csystem_error%3e "19.5.2Header <system_­error> synopsis[system.error.syn]"),[<thread>](thread.syn#header:%3cthread%3e "32.4.2Header <thread> synopsis[thread.syn]"),[<tuple>](tuple.syn#header:%3ctuple%3e "22.4.2Header <tuple> synopsis[tuple.syn]"),<typeindex> ([[type.index.synopsis]](type.index.synopsis "17.7.6Header <typeindex> synopsis")),[<type_traits>](meta.type.synop#header:%3ctype_traits%3e "21.3.3Header <type_­traits> synopsis[meta.type.synop]"),[<unordered_map>](unord.map.syn#header:%3cunordered_map%3e "23.5.2Header <unordered_­map> synopsis[unord.map.syn]"),
and[<unordered_set>](unord.set.syn#header:%3cunordered_set%3e "23.5.5Header <unordered_­set> synopsis[unord.set.syn]")[.](#2.sentence-3)
In addition the following C compatibility headers are new:[<cfenv>](cfenv.syn#header:%3ccfenv%3e "29.3.1Header <cfenv> synopsis[cfenv.syn]"),[<cinttypes>](cinttypes.syn#header:%3ccinttypes%3e "31.13.2Header <cinttypes> synopsis[cinttypes.syn]"),[<cstdint>](cstdint.syn#header:%3ccstdint%3e "17.4.1Header <cstdint> synopsis[cstdint.syn]"),
and[<cuchar>](cuchar.syn#header:%3ccuchar%3e "28.7.4Header <cuchar> synopsis[cuchar.syn]")[.](#2.sentence-4)
Valid C++ 2003 code that #includes headers with these names may be
invalid in this revision of C++[.](#2.sentence-5)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L2460)
**Affected subclause:** [[swappable.requirements]](swappable.requirements)
**Change:** Function swap moved to a different header[.](#3.sentence-1)
**Rationale:** Remove dependency on [<algorithm>](algorithm.syn#header:%3calgorithm%3e "26.4Header <algorithm> synopsis[algorithm.syn]") for swap[.](#3.sentence-2)
**Effect on original feature:** Valid C++ 2003 code that has been compiled expecting swap to be in[<algorithm>](algorithm.syn#header:%3calgorithm%3e "26.4Header <algorithm> synopsis[algorithm.syn]") may have to instead include [<utility>](utility.syn#header:%3cutility%3e "22.2.1Header <utility> synopsis[utility.syn]")[.](#3.sentence-3)
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L2469)
**Affected subclause:** [[namespace.posix]](namespace.posix)
**Change:** New reserved namespace[.](#4.sentence-1)
**Rationale:** New functionality[.](#4.sentence-2)
**Effect on original feature:** The global namespace posix is now reserved for standardization[.](#4.sentence-3)
Valid
C++ 2003 code that uses a top-level namespace posix may be invalid in
this revision of C++[.](#4.sentence-4)
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L2479)
**Affected subclause:** [[macro.names]](macro.names)
**Change:** Additional restrictions on macro names[.](#5.sentence-1)
**Rationale:** Avoid hard to diagnose or non-portable constructs[.](#5.sentence-2)
**Effect on original feature:** Names of attribute identifiers may not be used as macro names[.](#5.sentence-3)
Valid C++ 2003
code that defines override, final, ornoreturn as macros is invalid in this
revision of C++[.](#5.sentence-4)

View File

@@ -0,0 +1,26 @@
[diff.cpp03.locale]
# Annex C (informative) Compatibility [[diff]](./#diff)
## C.6 C++ and ISO C++ 2003 [[diff.cpp03]](diff.cpp03#locale)
### C.6.15 [[localization]](localization "28.3Localization library"): localization library [diff.cpp03.locale]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L2674)
**Affected subclause:** [[facet.num.get.virtuals]](facet.num.get.virtuals)
**Change:** The num_get facet recognizes hexadecimal floating point values[.](#1.sentence-1)
**Rationale:** Required by new feature[.](#1.sentence-2)
**Effect on original feature:** Valid C++ 2003 code may have different behavior in this revision of C++[.](#1.sentence-3)

View File

@@ -0,0 +1,27 @@
[diff.cpp03.numerics]
# Annex C (informative) Compatibility [[diff]](./#diff)
## C.6 C++ and ISO C++ 2003 [[diff.cpp03]](diff.cpp03#numerics)
### C.6.14 [[numerics]](numerics "29Numerics library"): numerics library [diff.cpp03.numerics]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L2662)
**Affected subclause:** [[complex.numbers]](complex.numbers)
**Change:** Specified representation of complex numbers[.](#1.sentence-1)
**Rationale:** Compatibility with C99[.](#1.sentence-2)
**Effect on original feature:** Valid C++ 2003 code that uses implementation-specific knowledge about the
binary representation of the required template specializations ofstd::complex may not be compatible with this revision of C++[.](#1.sentence-3)

View File

@@ -0,0 +1,51 @@
[diff.cpp03.strings]
# Annex C (informative) Compatibility [[diff]](./#diff)
## C.6 C++ and ISO C++ 2003 [[diff.cpp03]](diff.cpp03#strings)
### C.6.11 [[strings]](strings "27Strings library"): strings library [diff.cpp03.strings]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L2535)
**Affected subclause:** [[string.classes]](string.classes)
**Change:** basic_string requirements no longer allow reference-counted
strings[.](#1.sentence-1)
**Rationale:** Invalidation is subtly different with reference-counted strings[.](#1.sentence-2)
This change regularizes behavior[.](#1.sentence-3)
**Effect on original feature:** Valid C++ 2003 code may execute differently in this revision of C++[.](#1.sentence-4)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L2545)
**Affected subclause:** [[string.require]](string.require)
**Change:** Loosen basic_string invalidation rules[.](#2.sentence-1)
**Rationale:** Allow small-string optimization[.](#2.sentence-2)
**Effect on original feature:** Valid C++ 2003 code may execute differently in this revision of C++[.](#2.sentence-3)
Some const member functions, such as data and c_str,
no longer invalidate iterators[.](#2.sentence-4)

View File

@@ -0,0 +1,83 @@
[diff.cpp03.temp]
# Annex C (informative) Compatibility [[diff]](./#diff)
## C.6 C++ and ISO C++ 2003 [[diff.cpp03]](diff.cpp03#temp)
### C.6.6 [[temp]](temp "13Templates"): templates [diff.cpp03.temp]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L2369)
**Affected subclause:** [[temp.param]](temp.param)
**Change:** Repurpose export for modules ([[module]](module "10Modules"), [[cpp.module]](cpp.module "15.5Module directive"), [[cpp.import]](cpp.import "15.6Header unit importation"))[.](#1.sentence-1)
**Rationale:** No implementation consensus for the C++ 2003 meaning of export[.](#1.sentence-2)
**Effect on original feature:** A valid C++ 2003 program containing export is ill-formed in this
revision of C++[.](#1.sentence-3)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L2378)
**Affected subclause:** [[temp.arg]](temp.arg)
**Change:** Remove whitespace requirement for nested closing template right angle
brackets[.](#2.sentence-1)
**Rationale:** Considered a persistent but minor annoyance[.](#2.sentence-2)
Template aliases
representing non-class types would exacerbate whitespace issues[.](#2.sentence-3)
**Effect on original feature:** Change to semantics of well-defined expression[.](#2.sentence-4)
A valid C++ 2003 expression
containing a right angle bracket (“>”) followed immediately by
another right angle bracket may now be treated as closing two templates[.](#2.sentence-5)
[*Example [1](#example-1)*: template <class T> struct X { };template <int N> struct Y { };
X< Y< 1 >> 2 > > x;
This code is valid in C++ 2003 because “>>”
is a right-shift operator, but invalid in this revision of C++ because
“>>” closes two templates[.](#2.sentence-6)
— *end example*]
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L2400)
**Affected subclause:** [[temp.dep.candidate]](temp.dep.candidate)
**Change:** Allow dependent calls of functions with internal linkage[.](#3.sentence-1)
**Rationale:** Overly constrained, simplify overload resolution rules[.](#3.sentence-2)
**Effect on original feature:** A valid C++ 2003 program can get a different result in this
revision of C++[.](#3.sentence-3)

View File

@@ -0,0 +1,27 @@
[diff.cpp03.utilities]
# Annex C (informative) Compatibility [[diff]](./#diff)
## C.6 C++ and ISO C++ 2003 [[diff.cpp03]](diff.cpp03#utilities)
### C.6.10 [[utilities]](utilities "22General utilities library"): general utilities library [diff.cpp03.utilities]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L2521)
**Affected subclauses:** [[refwrap]](refwrap), [[arithmetic.operations]](arithmetic.operations), [[comparisons]](comparisons), [[logical.operations]](logical.operations), and [[bitwise.operations]](bitwise.operations)
**Change:** Standard function object types no longer derived fromstd::unary_function or std::binary_function[.](#1.sentence-1)
**Rationale:** Superseded by new feature; unary_function andbinary_function are no longer defined[.](#1.sentence-2)
**Effect on original feature:** Valid C++ 2003 code that depends on function object types being derived fromunary_function or binary_function may fail to compile
in this revision of C++[.](#1.sentence-3)

213
cppdraft/diff/cpp11.md Normal file
View File

@@ -0,0 +1,213 @@
[diff.cpp11]
# Annex C (informative) Compatibility [[diff]](./#diff)
## C.5 C++ and ISO C++ 2011 [diff.cpp11]
### [C.5.1](#general) General [[diff.cpp11.general]](diff.cpp11.general)
[1](#general-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L1964)
Subclause [diff.cpp11] lists the differences between C++ and
ISO C++ 2011,
in addition to those listed above,
by the chapters of this document[.](#general-1.sentence-1)
### [C.5.2](#lex) [[lex]](lex "5Lexical conventions"): lexical conventions [[diff.cpp11.lex]](diff.cpp11.lex)
[1](#lex-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L1973)
**Affected subclause:** [[lex.ppnumber]](lex.ppnumber)
**Change:** [*pp-number*](lex.ppnumber#nt:pp-number "5.7Preprocessing numbers[lex.ppnumber]") can contain one or more single quotes[.](#lex-1.sentence-1)
**Rationale:** Necessary to enable single quotes as digit separators[.](#lex-1.sentence-2)
**Effect on original feature:** Valid C++ 2011 code may fail to compile or may change meaning in this
revision of C++[.](#lex-1.sentence-3)
For example, the following code is valid both in C++ 2011 and in
this revision of C++, but the macro invocation produces different outcomes
because the single quotes delimit a [*character-literal*](lex.ccon#nt:character-literal "5.13.3Character literals[lex.ccon]") in C++ 2011, whereas they are digit
separators in this revision of C++[.](#lex-1.sentence-4)
[*Example [1](#lex-example-1)*: #define M(x, ...) __VA_ARGS__int x[2] = { M(1'2,3'4, 5) };// int x[2] = { 5 }; --- C++ 2011// int x[2] = { 3'4, 5 }; --- this revision of C++ — *end example*]
### [C.5.3](#basic) [[basic]](basic "6Basics"): basics [[diff.cpp11.basic]](diff.cpp11.basic)
[1](#basic-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L1995)
**Affected subclause:** [[basic.stc.dynamic.deallocation]](basic.stc.dynamic.deallocation)
**Change:** New usual (non-placement) deallocator[.](#basic-1.sentence-1)
**Rationale:** Required for sized deallocation[.](#basic-1.sentence-2)
**Effect on original feature:** Valid C++ 2011 code can declare a global placement allocation function and
deallocation function as follows:void* operator new(std::size_t, std::size_t);void operator delete(void*, std::size_t) noexcept;
In this revision of C++, however, the declaration of operator delete might match a predefined usual (non-placement)operator delete ([[basic.stc.dynamic]](basic.stc.dynamic "6.8.6.5Dynamic storage duration"))[.](#basic-1.sentence-4)
If so, the
program is ill-formed, as it was for class member allocation functions and
deallocation functions ([[expr.new]](expr.new "7.6.2.8New"))[.](#basic-1.sentence-5)
### [C.5.4](#expr) [[expr]](expr "7Expressions"): expressions [[diff.cpp11.expr]](diff.cpp11.expr)
[1](#expr-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L2015)
**Affected subclause:** [[expr.cond]](expr.cond)
**Change:** A conditional expression with a throw expression as its second or third
operand keeps the type and value category of the other operand[.](#expr-1.sentence-1)
**Rationale:** Formerly mandated conversions ([lvalue-to-rvalue](conv.lval "7.3.2Lvalue-to-rvalue conversion[conv.lval]"),[array-to-pointer](conv.array "7.3.3Array-to-pointer conversion[conv.array]"), and [function-to-pointer](conv.func "7.3.4Function-to-pointer conversion[conv.func]") standard conversions), especially the creation of the temporary due to
lvalue-to-rvalue conversion, were considered gratuitous and surprising[.](#expr-1.sentence-2)
**Effect on original feature:** Valid C++ 2011 code that relies on the conversions may behave differently
in this revision of C++[.](#expr-1.sentence-3)
[*Example [1](#expr-example-1)*: struct S {int x = 1; void mf() { x = 2; }};int f(bool cond) { S s; (cond ? s : throw 0).mf(); return s.x;}
In C++ 2011, f(true) returns 1[.](#expr-1.sentence-4)
In this revision of C++,
it returns 2[.](#expr-1.sentence-5)
sizeof(true ? "" : throw 0)
In C++ 2011, the expression yields sizeof(const char*)[.](#expr-1.sentence-6)
In this
revision of C++, it yields sizeof(const char[1])[.](#expr-1.sentence-7)
— *end example*]
### [C.5.5](#dcl.dcl) [[dcl]](dcl "9Declarations"): declarations [[diff.cpp11.dcl.dcl]](diff.cpp11.dcl.dcl)
[1](#dcl.dcl-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L2050)
**Affected subclause:** [[dcl.constexpr]](dcl.constexpr)
**Change:** constexpr non-static member functions are not implicitlyconst member functions[.](#dcl.dcl-1.sentence-1)
**Rationale:** Necessary to allow constexpr member functions to mutate
the object[.](#dcl.dcl-1.sentence-2)
**Effect on original feature:** Valid C++ 2011 code may fail to compile in this revision of C++[.](#dcl.dcl-1.sentence-3)
[*Example [1](#dcl.dcl-example-1)*: struct S {constexpr const int &f(); int &f();};
This code is valid in C++ 2011
but invalid in this revision of C++ because it declares the same member
function twice with different return types[.](#dcl.dcl-1.sentence-4)
— *end example*]
[2](#dcl.dcl-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L2071)
**Affected subclause:** [[dcl.init.aggr]](dcl.init.aggr)
**Change:** Classes with default member initializers can be aggregates[.](#dcl.dcl-2.sentence-1)
**Rationale:** Necessary to allow default member initializers to be used
by aggregate initialization[.](#dcl.dcl-2.sentence-2)
**Effect on original feature:** Valid C++ 2011 code may fail to compile or may change meaning in this revision of C++[.](#dcl.dcl-2.sentence-3)
[*Example [2](#dcl.dcl-example-2)*: struct S { // Aggregate in C++ 2014 onwards.int m = 1;};struct X {operator int(); operator S();};
X a{};
S b{a}; // uses copy constructor in C++ 2011,// performs aggregate initialization in this revision of C++ — *end example*]
### [C.5.6](#library) [[library]](library "16Library introduction"): library introduction [[diff.cpp11.library]](diff.cpp11.library)
[1](#library-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L2096)
**Affected subclause:** [[headers]](headers)
**Change:** New header[.](#library-1.sentence-1)
**Rationale:** New functionality[.](#library-1.sentence-2)
**Effect on original feature:** The C++ header [<shared_mutex>](shared.mutex.syn#header:%3cshared_mutex%3e "32.6.3Header <shared_­mutex> synopsis[shared.mutex.syn]") is new[.](#library-1.sentence-3)
Valid C++ 2011 code that #includes a header with that name may be
invalid in this revision of C++[.](#library-1.sentence-4)
### [C.5.7](#input.output) [[input.output]](input.output "31Input/output library"): input/output library [[diff.cpp11.input.output]](diff.cpp11.input.output)
[1](#input.output-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L2108)
**Affected subclause:** [[c.files]](c.files)
**Change:** gets is not defined[.](#input.output-1.sentence-1)
**Rationale:** Use of gets is considered dangerous[.](#input.output-1.sentence-2)
**Effect on original feature:** Valid C++ 2011 code that uses the gets function may fail to compile
in this revision of C++[.](#input.output-1.sentence-3)

View File

@@ -0,0 +1,33 @@
[diff.cpp11.basic]
# Annex C (informative) Compatibility [[diff]](./#diff)
## C.5 C++ and ISO C++ 2011 [[diff.cpp11]](diff.cpp11#basic)
### C.5.3 [[basic]](basic "6Basics"): basics [diff.cpp11.basic]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L1995)
**Affected subclause:** [[basic.stc.dynamic.deallocation]](basic.stc.dynamic.deallocation)
**Change:** New usual (non-placement) deallocator[.](#1.sentence-1)
**Rationale:** Required for sized deallocation[.](#1.sentence-2)
**Effect on original feature:** Valid C++ 2011 code can declare a global placement allocation function and
deallocation function as follows:void* operator new(std::size_t, std::size_t);void operator delete(void*, std::size_t) noexcept;
In this revision of C++, however, the declaration of operator delete might match a predefined usual (non-placement)operator delete ([[basic.stc.dynamic]](basic.stc.dynamic "6.8.6.5Dynamic storage duration"))[.](#1.sentence-4)
If so, the
program is ill-formed, as it was for class member allocation functions and
deallocation functions ([[expr.new]](expr.new "7.6.2.8New"))[.](#1.sentence-5)

View File

@@ -0,0 +1,59 @@
[diff.cpp11.dcl.dcl]
# Annex C (informative) Compatibility [[diff]](./#diff)
## C.5 C++ and ISO C++ 2011 [[diff.cpp11]](diff.cpp11#dcl.dcl)
### C.5.5 [[dcl]](dcl "9Declarations"): declarations [diff.cpp11.dcl.dcl]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L2050)
**Affected subclause:** [[dcl.constexpr]](dcl.constexpr)
**Change:** constexpr non-static member functions are not implicitlyconst member functions[.](#1.sentence-1)
**Rationale:** Necessary to allow constexpr member functions to mutate
the object[.](#1.sentence-2)
**Effect on original feature:** Valid C++ 2011 code may fail to compile in this revision of C++[.](#1.sentence-3)
[*Example [1](#example-1)*: struct S {constexpr const int &f(); int &f();};
This code is valid in C++ 2011
but invalid in this revision of C++ because it declares the same member
function twice with different return types[.](#1.sentence-4)
— *end example*]
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L2071)
**Affected subclause:** [[dcl.init.aggr]](dcl.init.aggr)
**Change:** Classes with default member initializers can be aggregates[.](#2.sentence-1)
**Rationale:** Necessary to allow default member initializers to be used
by aggregate initialization[.](#2.sentence-2)
**Effect on original feature:** Valid C++ 2011 code may fail to compile or may change meaning in this revision of C++[.](#2.sentence-3)
[*Example [2](#example-2)*: struct S { // Aggregate in C++ 2014 onwards.int m = 1;};struct X {operator int(); operator S();};
X a{};
S b{a}; // uses copy constructor in C++ 2011,// performs aggregate initialization in this revision of C++ — *end example*]

View File

@@ -0,0 +1,45 @@
[diff.cpp11.expr]
# Annex C (informative) Compatibility [[diff]](./#diff)
## C.5 C++ and ISO C++ 2011 [[diff.cpp11]](diff.cpp11#expr)
### C.5.4 [[expr]](expr "7Expressions"): expressions [diff.cpp11.expr]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L2015)
**Affected subclause:** [[expr.cond]](expr.cond)
**Change:** A conditional expression with a throw expression as its second or third
operand keeps the type and value category of the other operand[.](#1.sentence-1)
**Rationale:** Formerly mandated conversions ([lvalue-to-rvalue](conv.lval "7.3.2Lvalue-to-rvalue conversion[conv.lval]"),[array-to-pointer](conv.array "7.3.3Array-to-pointer conversion[conv.array]"), and [function-to-pointer](conv.func "7.3.4Function-to-pointer conversion[conv.func]") standard conversions), especially the creation of the temporary due to
lvalue-to-rvalue conversion, were considered gratuitous and surprising[.](#1.sentence-2)
**Effect on original feature:** Valid C++ 2011 code that relies on the conversions may behave differently
in this revision of C++[.](#1.sentence-3)
[*Example [1](#example-1)*: struct S {int x = 1; void mf() { x = 2; }};int f(bool cond) { S s; (cond ? s : throw 0).mf(); return s.x;}
In C++ 2011, f(true) returns 1[.](#1.sentence-4)
In this revision of C++,
it returns 2[.](#1.sentence-5)
sizeof(true ? "" : throw 0)
In C++ 2011, the expression yields sizeof(const char*)[.](#1.sentence-6)
In this
revision of C++, it yields sizeof(const char[1])[.](#1.sentence-7)
— *end example*]

View File

@@ -0,0 +1,16 @@
[diff.cpp11.general]
# Annex C (informative) Compatibility [[diff]](./#diff)
## C.5 C++ and ISO C++ 2011 [[diff.cpp11]](diff.cpp11#general)
### C.5.1 General [diff.cpp11.general]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L1964)
Subclause [[diff.cpp11]](diff.cpp11 "C.5C++ and ISO C++ 2011") lists the differences between C++ and
ISO C++ 2011,
in addition to those listed above,
by the chapters of this document[.](#1.sentence-1)

View File

@@ -0,0 +1,27 @@
[diff.cpp11.input.output]
# Annex C (informative) Compatibility [[diff]](./#diff)
## C.5 C++ and ISO C++ 2011 [[diff.cpp11]](diff.cpp11#input.output)
### C.5.7 [[input.output]](input.output "31Input/output library"): input/output library [diff.cpp11.input.output]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L2108)
**Affected subclause:** [[c.files]](c.files)
**Change:** gets is not defined[.](#1.sentence-1)
**Rationale:** Use of gets is considered dangerous[.](#1.sentence-2)
**Effect on original feature:** Valid C++ 2011 code that uses the gets function may fail to compile
in this revision of C++[.](#1.sentence-3)

View File

@@ -0,0 +1,34 @@
[diff.cpp11.lex]
# Annex C (informative) Compatibility [[diff]](./#diff)
## C.5 C++ and ISO C++ 2011 [[diff.cpp11]](diff.cpp11#lex)
### C.5.2 [[lex]](lex "5Lexical conventions"): lexical conventions [diff.cpp11.lex]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L1973)
**Affected subclause:** [[lex.ppnumber]](lex.ppnumber)
**Change:** [*pp-number*](lex.ppnumber#nt:pp-number "5.7Preprocessing numbers[lex.ppnumber]") can contain one or more single quotes[.](#1.sentence-1)
**Rationale:** Necessary to enable single quotes as digit separators[.](#1.sentence-2)
**Effect on original feature:** Valid C++ 2011 code may fail to compile or may change meaning in this
revision of C++[.](#1.sentence-3)
For example, the following code is valid both in C++ 2011 and in
this revision of C++, but the macro invocation produces different outcomes
because the single quotes delimit a [*character-literal*](lex.ccon#nt:character-literal "5.13.3Character literals[lex.ccon]") in C++ 2011, whereas they are digit
separators in this revision of C++[.](#1.sentence-4)
[*Example [1](#example-1)*: #define M(x, ...) __VA_ARGS__int x[2] = { M(1'2,3'4, 5) };// int x[2] = { 5 }; --- C++ 2011// int x[2] = { 3'4, 5 }; --- this revision of C++ — *end example*]

View File

@@ -0,0 +1,29 @@
[diff.cpp11.library]
# Annex C (informative) Compatibility [[diff]](./#diff)
## C.5 C++ and ISO C++ 2011 [[diff.cpp11]](diff.cpp11#library)
### C.5.6 [[library]](library "16Library introduction"): library introduction [diff.cpp11.library]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L2096)
**Affected subclause:** [[headers]](headers)
**Change:** New header[.](#1.sentence-1)
**Rationale:** New functionality[.](#1.sentence-2)
**Effect on original feature:** The C++ header [<shared_mutex>](shared.mutex.syn#header:%3cshared_mutex%3e "32.6.3Header <shared_­mutex> synopsis[shared.mutex.syn]") is new[.](#1.sentence-3)
Valid C++ 2011 code that #includes a header with that name may be
invalid in this revision of C++[.](#1.sentence-4)

496
cppdraft/diff/cpp14.md Normal file
View File

@@ -0,0 +1,496 @@
[diff.cpp14]
# Annex C (informative) Compatibility [[diff]](./#diff)
## C.4 C++ and ISO C++ 2014 [diff.cpp14]
### [C.4.1](#general) General [[diff.cpp14.general]](diff.cpp14.general)
[1](#general-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L1594)
Subclause [diff.cpp14] lists the differences between C++ and
ISO C++ 2014,
in addition to those listed above,
by the chapters of this document[.](#general-1.sentence-1)
### [C.4.2](#lex) [[lex]](lex "5Lexical conventions"): lexical conventions [[diff.cpp14.lex]](diff.cpp14.lex)
[1](#lex-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L1603)
**Affected subclause:** [[lex.phases]](lex.phases)
**Change:** Removal of trigraph support as a required feature[.](#lex-1.sentence-1)
**Rationale:** Prevents accidental uses of trigraphs in non-raw string literals and comments[.](#lex-1.sentence-2)
**Effect on original feature:** Valid C++ 2014 code that uses trigraphs may not be valid or may have different
semantics in this revision of C++[.](#lex-1.sentence-3)
Implementations may choose to
translate trigraphs as specified in C++ 2014 if they appear outside of a raw
string literal, as part of theimplementation-defined
mapping from input source file characters to
the translation character set[.](#lex-1.sentence-4)
[2](#lex-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L1618)
**Affected subclause:** [[lex.ppnumber]](lex.ppnumber)
**Change:** [*pp-number*](lex.ppnumber#nt:pp-number "5.7Preprocessing numbers[lex.ppnumber]") can contain p [*sign*](lex.fcon#nt:sign "5.13.4Floating-point literals[lex.fcon]") andP [*sign*](lex.fcon#nt:sign "5.13.4Floating-point literals[lex.fcon]")[.](#lex-2.sentence-1)
**Rationale:** Necessary to enable [*hexadecimal-floating-point-literal*](lex.fcon#nt:hexadecimal-floating-point-literal "5.13.4Floating-point literals[lex.fcon]")*s*[.](#lex-2.sentence-2)
**Effect on original feature:** Valid C++ 2014 code may fail to compile or produce different results in
this revision of C++[.](#lex-2.sentence-3)
Specifically, character sequences like 0p+0 and 0e1_p+0 are three separate tokens each in C++ 2014, but one single token
in this revision of C++[.](#lex-2.sentence-4)
[*Example [1](#lex-example-1)*: #define F(a) b ## aint b0p = F(0p+0); // ill-formed; equivalent to “int b0p = b0p + 0;'' in C++ 2014 — *end example*]
### [C.4.3](#expr) [[expr]](expr "7Expressions"): expressions [[diff.cpp14.expr]](diff.cpp14.expr)
[1](#expr-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L1638)
**Affected subclauses:** [[expr.post.incr]](expr.post.incr) and [[expr.pre.incr]](expr.pre.incr)
**Change:** Remove increment operator with bool operand[.](#expr-1.sentence-1)
**Rationale:** Obsolete feature with occasionally surprising semantics[.](#expr-1.sentence-2)
**Effect on original feature:** A valid C++ 2014 expression utilizing the increment operator on
a bool lvalue is ill-formed in this revision of C++[.](#expr-1.sentence-3)
[2](#expr-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L1647)
**Affected subclauses:** [[expr.new]](expr.new) and [[expr.delete]](expr.delete)
**Change:** Dynamic allocation mechanism for over-aligned types[.](#expr-2.sentence-1)
**Rationale:** Simplify use of over-aligned types[.](#expr-2.sentence-2)
**Effect on original feature:** In C++ 2014 code that uses a [*new-expression*](expr.new#nt:new-expression "7.6.2.8New[expr.new]") to allocate an object with an over-aligned class type,
where that class has no allocation functions of its own,::operator new(std::size_t) is used to allocate the memory[.](#expr-2.sentence-3)
In this revision of C++,::operator new(std::size_t, std::align_val_t) is used instead[.](#expr-2.sentence-4)
### [C.4.4](#dcl.dcl) [[dcl]](dcl "9Declarations"): declarations [[diff.cpp14.dcl.dcl]](diff.cpp14.dcl.dcl)
[1](#dcl.dcl-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L1664)
**Affected subclause:** [[dcl.stc]](dcl.stc)
**Change:** Removal of register [*storage-class-specifier*](dcl.stc#nt:storage-class-specifier "9.2.2Storage class specifiers[dcl.stc]")[.](#dcl.dcl-1.sentence-1)
**Rationale:** Enable repurposing of deprecated keyword in future revisions of C++[.](#dcl.dcl-1.sentence-2)
**Effect on original feature:** A valid C++ 2014 declaration utilizing the register[*storage-class-specifier*](dcl.stc#nt:storage-class-specifier "9.2.2Storage class specifiers[dcl.stc]") is ill-formed in this revision of C++[.](#dcl.dcl-1.sentence-3)
The specifier can simply be removed to retain the original meaning[.](#dcl.dcl-1.sentence-4)
[2](#dcl.dcl-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L1675)
**Affected subclause:** [[dcl.spec.auto]](dcl.spec.auto)
**Change:** auto deduction from [*braced-init-list*](dcl.init.general#nt:braced-init-list "9.5.1General[dcl.init.general]")[.](#dcl.dcl-2.sentence-1)
**Rationale:** More intuitive deduction behavior[.](#dcl.dcl-2.sentence-2)
**Effect on original feature:** Valid C++ 2014 code may fail to compile or may change meaning
in this revision of C++[.](#dcl.dcl-2.sentence-3)
[*Example [1](#dcl.dcl-example-1)*: auto x1{1}; // was std::initializer_list<int>, now intauto x2{1, 2}; // was std::initializer_list<int>, now ill-formed — *end example*]
[3](#dcl.dcl-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L1690)
**Affected subclause:** [[dcl.fct]](dcl.fct)
**Change:** Make exception specifications be part of the type system[.](#dcl.dcl-3.sentence-1)
**Rationale:** Improve type-safety[.](#dcl.dcl-3.sentence-2)
**Effect on original feature:** Valid C++ 2014 code may fail to compile or change meaning in this
revision of C++[.](#dcl.dcl-3.sentence-3)
[*Example [2](#dcl.dcl-example-2)*: void g1() noexcept;void g2();template<class T> int f(T *, T *);int x = f(g1, g2); // ill-formed; previously well-formed — *end example*]
[4](#dcl.dcl-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L1707)
**Affected subclause:** [[dcl.init.aggr]](dcl.init.aggr)
**Change:** Definition of an aggregate is extended
to apply to user-defined types with base classes[.](#dcl.dcl-4.sentence-1)
**Rationale:** To increase convenience of aggregate initialization[.](#dcl.dcl-4.sentence-2)
**Effect on original feature:** Valid C++ 2014 code may fail to compile or produce different results in this
revision of C++; initialization from an empty initializer list will
perform aggregate initialization instead of invoking a default constructor
for the affected types[.](#dcl.dcl-4.sentence-3)
[*Example [3](#dcl.dcl-example-3)*: struct derived;struct base {friend struct derived;private: base();};struct derived : base {};
derived d1{}; // error; the code was well-formed in C++ 2014 derived d2; // still OK — *end example*]
### [C.4.5](#class) [[class]](class "11Classes"): classes [[diff.cpp14.class]](diff.cpp14.class)
[1](#class-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L1735)
**Affected subclause:** [[class.inhctor.init]](class.inhctor.init)
**Change:** Inheriting a constructor no longer injects a constructor into the derived class[.](#class-1.sentence-1)
**Rationale:** Better interaction with other language features[.](#class-1.sentence-2)
**Effect on original feature:** Valid C++ 2014 code that uses inheriting constructors may not be valid
or may have different semantics[.](#class-1.sentence-3)
A [*using-declaration*](namespace.udecl#nt:using-declaration "9.10The using declaration[namespace.udecl]") that names a constructor now makes the corresponding base class constructors
visible to initializations of the derived class
rather than declaring additional derived class constructors[.](#class-1.sentence-4)
[*Example [1](#class-example-1)*: struct A {template<typename T> A(T, typename T::type = 0);
A(int);};struct B : A {using A::A;
B(int);};
B b(42L); // now calls B(int), used to call B<long>(long),// which called A(int) due to substitution failure// in A<long>(long). — *end example*]
### [C.4.6](#temp) [[temp]](temp "13Templates"): templates [[diff.cpp14.temp]](diff.cpp14.temp)
[1](#temp-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L1764)
**Affected subclause:** [[temp.deduct.type]](temp.deduct.type)
**Change:** Allowance to deduce from the type of a constant template argument[.](#temp-1.sentence-1)
**Rationale:** In combination with the ability to declare
constant template arguments with placeholder types,
allows partial specializations to decompose
from the type deduced for the constant template argument[.](#temp-1.sentence-2)
**Effect on original feature:** Valid C++ 2014 code may fail to compile
or produce different results in this revision of C++[.](#temp-1.sentence-3)
[*Example [1](#temp-example-1)*: template <int N> struct A;template <typename T, T N> int foo(A<N> *) = delete;void foo(void *);void bar(A<0> *p) { foo(p); // ill-formed; previously well-formed} — *end example*]
### [C.4.7](#except) [[except]](except "14Exception handling"): exception handling [[diff.cpp14.except]](diff.cpp14.except)
[1](#except-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L1788)
**Affected subclause:** [[except.spec]](except.spec)
**Change:** Remove dynamic exception specifications[.](#except-1.sentence-1)
**Rationale:** Dynamic exception specifications were a deprecated feature
that was complex and brittle in use[.](#except-1.sentence-2)
They interacted badly with the type system,
which became a more significant issue in this revision of C++
where (non-dynamic) exception specifications are part of the function type[.](#except-1.sentence-3)
**Effect on original feature:** A valid C++ 2014 function declaration,
member function declaration,
function pointer declaration,
or function reference declaration,
if it has a potentially throwing dynamic exception specification,
is rejected as ill-formed in this revision of C++[.](#except-1.sentence-4)
Violating a non-throwing dynamic exception specification
calls terminate rather than unexpected,
and it is unspecified whether stack unwinding is performed
prior to such a call[.](#except-1.sentence-5)
### [C.4.8](#library) [[library]](library "16Library introduction"): library introduction [[diff.cpp14.library]](diff.cpp14.library)
[1](#library-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L1811)
**Affected subclause:** [[headers]](headers)
**Change:** New headers[.](#library-1.sentence-1)
**Rationale:** New functionality[.](#library-1.sentence-2)
**Effect on original feature:** The following C++ headers are new:[<any>](any.synop#header:%3cany%3e "22.7.2Header <any> synopsis[any.synop]"),[<charconv>](charconv.syn#header:%3ccharconv%3e "28.2.1Header <charconv> synopsis[charconv.syn]"),[<execution>](execution.syn#header:%3cexecution%3e "33.4Header <execution> synopsis[execution.syn]"),[<filesystem>](fs.filesystem.syn#header:%3cfilesystem%3e "31.12.4Header <filesystem> synopsis[fs.filesystem.syn]"),[<memory_resource>](mem.res.syn#header:%3cmemory_resource%3e "20.5.1Header <memory_­resource> synopsis[mem.res.syn]"),[<optional>](optional.syn#header:%3coptional%3e "22.5.2Header <optional> synopsis[optional.syn]"),
[<string_view>](string.view.synop#header:%3cstring_view%3e "27.3.2Header <string_­view> synopsis[string.view.synop]"),
and[<variant>](variant.syn#header:%3cvariant%3e "22.6.2Header <variant> synopsis[variant.syn]")[.](#library-1.sentence-4)
Valid C++ 2014 code that #includes headers with these names may be
invalid in this revision of C++[.](#library-1.sentence-5)
[2](#library-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L1830)
**Affected subclause:** [[namespace.future]](namespace.future)
**Change:** New reserved namespaces[.](#library-2.sentence-1)
**Rationale:** Reserve namespaces for future revisions of the standard library
that might otherwise be incompatible with existing programs[.](#library-2.sentence-2)
**Effect on original feature:** The global namespaces std followed by an arbitrary sequence of [*digit*](lex.name#nt:digit "5.11Identifiers[lex.name]")*s* ([[lex.name]](lex.name "5.11Identifiers"))
are reserved for future standardization[.](#library-2.sentence-3)
Valid C++ 2014 code that uses such a top-level namespace,
e.g., std2, may be invalid in this revision of C++[.](#library-2.sentence-4)
### [C.4.9](#utilities) [[utilities]](utilities "22General utilities library"): general utilities library [[diff.cpp14.utilities]](diff.cpp14.utilities)
[1](#utilities-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L1845)
**Affected subclause:** [[func.wrap]](func.wrap)
**Change:** Constructors taking allocators removed[.](#utilities-1.sentence-1)
**Rationale:** No implementation consensus[.](#utilities-1.sentence-2)
**Effect on original feature:** Valid C++ 2014 code may fail to compile or may change meaning in this
revision of C++[.](#utilities-1.sentence-3)
Specifically, constructing a std::function with
an allocator is ill-formed and uses-allocator construction will not pass an
allocator to std::function constructors in this revision of C++[.](#utilities-1.sentence-4)
[2](#utilities-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L1856)
**Affected subclause:** [[util.smartptr.shared]](util.smartptr.shared)
**Change:** Different constraint on conversions from unique_ptr[.](#utilities-2.sentence-1)
**Rationale:** Adding array support to shared_ptr,
via the syntax shared_ptr<T[]> and shared_ptr<T[N]>[.](#utilities-2.sentence-2)
**Effect on original feature:** Valid C++ 2014 code may fail to compile or may change meaning in this
revision of C++[.](#utilities-2.sentence-3)
[*Example [1](#utilities-example-1)*: #include <memory> std::unique_ptr<int[]> arr(new int[1]);
std::shared_ptr<int> ptr(std::move(arr)); // error: int(*)[] is not compatible with int* — *end example*]
### [C.4.10](#string) [[strings]](strings "27Strings library"): strings library [[diff.cpp14.string]](diff.cpp14.string)
[1](#string-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L1875)
**Affected subclause:** [[basic.string]](basic.string)
**Change:** Non-const .data() member added[.](#string-1.sentence-1)
**Rationale:** The lack of a non-const .data() differed from the similar member of std::vector[.](#string-1.sentence-2)
This change regularizes behavior[.](#string-1.sentence-3)
**Effect on original feature:** Overloaded functions which have differing code paths
for char* and const char* arguments
will execute differently
when called with a non-const string's .data() member
in this revision of C++[.](#string-1.sentence-4)
[*Example [1](#string-example-1)*: int f(char *) = delete;int f(const char *);
string s;int x = f(s.data()); // ill-formed; previously well-formed — *end example*]
### [C.4.11](#containers) [[containers]](containers "23Containers library"): containers library [[diff.cpp14.containers]](diff.cpp14.containers)
[1](#containers-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L1899)
**Affected subclause:** [[associative.reqmts]](associative.reqmts)
**Change:** Requirements change:
**Rationale:** Increase portability, clarification of associative container requirements[.](#containers-1.sentence-2)
**Effect on original feature:** Valid C++ 2014 code that attempts to use associative containers
having a comparison object with non-const function call operator
may fail to compile in this revision of C++[.](#containers-1.sentence-3)
[*Example [1](#containers-example-1)*: #include <set>struct compare{bool operator()(int a, int b){return a < b; }};
int main() {const std::set<int, compare> s;
s.find(0);} — *end example*]
### [C.4.12](#depr) [[depr]](depr "Annex D(normative)Compatibility features"): compatibility features [[diff.cpp14.depr]](diff.cpp14.depr)
[1](#depr-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L1930)
**Change:** The class templatesauto_ptr,unary_function, andbinary_function,
the function templatesrandom_shuffle,
and the function templates (and their return types)ptr_fun,mem_fun,mem_fun_ref,bind1st, andbind2nd are not defined[.](#depr-1.sentence-1)
**Rationale:** Superseded by new features[.](#depr-1.sentence-2)
**Effect on original feature:** Valid C++ 2014 code that uses these class templates
and function templates may fail to compile in this revision of C++[.](#depr-1.sentence-3)
[2](#depr-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L1951)
**Change:** Remove old iostreams members [depr.ios.members][.](#depr-2.sentence-1)
**Rationale:** Redundant feature for compatibility with pre-standard code
has served its time[.](#depr-2.sentence-2)
**Effect on original feature:** A valid C++ 2014 program using these identifiers
may be ill-formed in this revision of C++[.](#depr-2.sentence-3)

View File

@@ -0,0 +1,36 @@
[diff.cpp14.class]
# Annex C (informative) Compatibility [[diff]](./#diff)
## C.4 C++ and ISO C++ 2014 [[diff.cpp14]](diff.cpp14#class)
### C.4.5 [[class]](class "11Classes"): classes [diff.cpp14.class]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L1735)
**Affected subclause:** [[class.inhctor.init]](class.inhctor.init)
**Change:** Inheriting a constructor no longer injects a constructor into the derived class[.](#1.sentence-1)
**Rationale:** Better interaction with other language features[.](#1.sentence-2)
**Effect on original feature:** Valid C++ 2014 code that uses inheriting constructors may not be valid
or may have different semantics[.](#1.sentence-3)
A [*using-declaration*](namespace.udecl#nt:using-declaration "9.10The using declaration[namespace.udecl]") that names a constructor now makes the corresponding base class constructors
visible to initializations of the derived class
rather than declaring additional derived class constructors[.](#1.sentence-4)
[*Example [1](#example-1)*: struct A {template<typename T> A(T, typename T::type = 0);
A(int);};struct B : A {using A::A;
B(int);};
B b(42L); // now calls B(int), used to call B<long>(long),// which called A(int) due to substitution failure// in A<long>(long). — *end example*]

View File

@@ -0,0 +1,30 @@
[diff.cpp14.containers]
# Annex C (informative) Compatibility [[diff]](./#diff)
## C.4 C++ and ISO C++ 2014 [[diff.cpp14]](diff.cpp14#containers)
### C.4.11 [[containers]](containers "23Containers library"): containers library [diff.cpp14.containers]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L1899)
**Affected subclause:** [[associative.reqmts]](associative.reqmts)
**Change:** Requirements change:
**Rationale:** Increase portability, clarification of associative container requirements[.](#1.sentence-2)
**Effect on original feature:** Valid C++ 2014 code that attempts to use associative containers
having a comparison object with non-const function call operator
may fail to compile in this revision of C++[.](#1.sentence-3)
[*Example [1](#example-1)*: #include <set>struct compare{bool operator()(int a, int b){return a < b; }};
int main() {const std::set<int, compare> s;
s.find(0);} — *end example*]

View File

@@ -0,0 +1,99 @@
[diff.cpp14.dcl.dcl]
# Annex C (informative) Compatibility [[diff]](./#diff)
## C.4 C++ and ISO C++ 2014 [[diff.cpp14]](diff.cpp14#dcl.dcl)
### C.4.4 [[dcl]](dcl "9Declarations"): declarations [diff.cpp14.dcl.dcl]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L1664)
**Affected subclause:** [[dcl.stc]](dcl.stc)
**Change:** Removal of register [*storage-class-specifier*](dcl.stc#nt:storage-class-specifier "9.2.2Storage class specifiers[dcl.stc]")[.](#1.sentence-1)
**Rationale:** Enable repurposing of deprecated keyword in future revisions of C++[.](#1.sentence-2)
**Effect on original feature:** A valid C++ 2014 declaration utilizing the register[*storage-class-specifier*](dcl.stc#nt:storage-class-specifier "9.2.2Storage class specifiers[dcl.stc]") is ill-formed in this revision of C++[.](#1.sentence-3)
The specifier can simply be removed to retain the original meaning[.](#1.sentence-4)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L1675)
**Affected subclause:** [[dcl.spec.auto]](dcl.spec.auto)
**Change:** auto deduction from [*braced-init-list*](dcl.init.general#nt:braced-init-list "9.5.1General[dcl.init.general]")[.](#2.sentence-1)
**Rationale:** More intuitive deduction behavior[.](#2.sentence-2)
**Effect on original feature:** Valid C++ 2014 code may fail to compile or may change meaning
in this revision of C++[.](#2.sentence-3)
[*Example [1](#example-1)*: auto x1{1}; // was std::initializer_list<int>, now intauto x2{1, 2}; // was std::initializer_list<int>, now ill-formed — *end example*]
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L1690)
**Affected subclause:** [[dcl.fct]](dcl.fct)
**Change:** Make exception specifications be part of the type system[.](#3.sentence-1)
**Rationale:** Improve type-safety[.](#3.sentence-2)
**Effect on original feature:** Valid C++ 2014 code may fail to compile or change meaning in this
revision of C++[.](#3.sentence-3)
[*Example [2](#example-2)*: void g1() noexcept;void g2();template<class T> int f(T *, T *);int x = f(g1, g2); // ill-formed; previously well-formed — *end example*]
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L1707)
**Affected subclause:** [[dcl.init.aggr]](dcl.init.aggr)
**Change:** Definition of an aggregate is extended
to apply to user-defined types with base classes[.](#4.sentence-1)
**Rationale:** To increase convenience of aggregate initialization[.](#4.sentence-2)
**Effect on original feature:** Valid C++ 2014 code may fail to compile or produce different results in this
revision of C++; initialization from an empty initializer list will
perform aggregate initialization instead of invoking a default constructor
for the affected types[.](#4.sentence-3)
[*Example [3](#example-3)*: struct derived;struct base {friend struct derived;private: base();};struct derived : base {};
derived d1{}; // error; the code was well-formed in C++ 2014 derived d2; // still OK — *end example*]

View File

@@ -0,0 +1,44 @@
[diff.cpp14.depr]
# Annex C (informative) Compatibility [[diff]](./#diff)
## C.4 C++ and ISO C++ 2014 [[diff.cpp14]](diff.cpp14#depr)
### C.4.12 [[depr]](depr "Annex D(normative)Compatibility features"): compatibility features [diff.cpp14.depr]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L1930)
**Change:** The class templatesauto_ptr,unary_function, andbinary_function,
the function templatesrandom_shuffle,
and the function templates (and their return types)ptr_fun,mem_fun,mem_fun_ref,bind1st, andbind2nd are not defined[.](#1.sentence-1)
**Rationale:** Superseded by new features[.](#1.sentence-2)
**Effect on original feature:** Valid C++ 2014 code that uses these class templates
and function templates may fail to compile in this revision of C++[.](#1.sentence-3)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L1951)
**Change:** Remove old iostreams members [depr.ios.members][.](#2.sentence-1)
**Rationale:** Redundant feature for compatibility with pre-standard code
has served its time[.](#2.sentence-2)
**Effect on original feature:** A valid C++ 2014 program using these identifiers
may be ill-formed in this revision of C++[.](#2.sentence-3)

View File

@@ -0,0 +1,41 @@
[diff.cpp14.except]
# Annex C (informative) Compatibility [[diff]](./#diff)
## C.4 C++ and ISO C++ 2014 [[diff.cpp14]](diff.cpp14#except)
### C.4.7 [[except]](except "14Exception handling"): exception handling [diff.cpp14.except]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L1788)
**Affected subclause:** [[except.spec]](except.spec)
**Change:** Remove dynamic exception specifications[.](#1.sentence-1)
**Rationale:** Dynamic exception specifications were a deprecated feature
that was complex and brittle in use[.](#1.sentence-2)
They interacted badly with the type system,
which became a more significant issue in this revision of C++
where (non-dynamic) exception specifications are part of the function type[.](#1.sentence-3)
**Effect on original feature:** A valid C++ 2014 function declaration,
member function declaration,
function pointer declaration,
or function reference declaration,
if it has a potentially throwing dynamic exception specification,
is rejected as ill-formed in this revision of C++[.](#1.sentence-4)
Violating a non-throwing dynamic exception specification
calls terminate rather than unexpected,
and it is unspecified whether stack unwinding is performed
prior to such a call[.](#1.sentence-5)

View File

@@ -0,0 +1,49 @@
[diff.cpp14.expr]
# Annex C (informative) Compatibility [[diff]](./#diff)
## C.4 C++ and ISO C++ 2014 [[diff.cpp14]](diff.cpp14#expr)
### C.4.3 [[expr]](expr "7Expressions"): expressions [diff.cpp14.expr]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L1638)
**Affected subclauses:** [[expr.post.incr]](expr.post.incr) and [[expr.pre.incr]](expr.pre.incr)
**Change:** Remove increment operator with bool operand[.](#1.sentence-1)
**Rationale:** Obsolete feature with occasionally surprising semantics[.](#1.sentence-2)
**Effect on original feature:** A valid C++ 2014 expression utilizing the increment operator on
a bool lvalue is ill-formed in this revision of C++[.](#1.sentence-3)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L1647)
**Affected subclauses:** [[expr.new]](expr.new) and [[expr.delete]](expr.delete)
**Change:** Dynamic allocation mechanism for over-aligned types[.](#2.sentence-1)
**Rationale:** Simplify use of over-aligned types[.](#2.sentence-2)
**Effect on original feature:** In C++ 2014 code that uses a [*new-expression*](expr.new#nt:new-expression "7.6.2.8New[expr.new]") to allocate an object with an over-aligned class type,
where that class has no allocation functions of its own,::operator new(std::size_t) is used to allocate the memory[.](#2.sentence-3)
In this revision of C++,::operator new(std::size_t, std::align_val_t) is used instead[.](#2.sentence-4)

View File

@@ -0,0 +1,16 @@
[diff.cpp14.general]
# Annex C (informative) Compatibility [[diff]](./#diff)
## C.4 C++ and ISO C++ 2014 [[diff.cpp14]](diff.cpp14#general)
### C.4.1 General [diff.cpp14.general]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L1594)
Subclause [[diff.cpp14]](diff.cpp14 "C.4C++ and ISO C++ 2014") lists the differences between C++ and
ISO C++ 2014,
in addition to those listed above,
by the chapters of this document[.](#1.sentence-1)

View File

@@ -0,0 +1,58 @@
[diff.cpp14.lex]
# Annex C (informative) Compatibility [[diff]](./#diff)
## C.4 C++ and ISO C++ 2014 [[diff.cpp14]](diff.cpp14#lex)
### C.4.2 [[lex]](lex "5Lexical conventions"): lexical conventions [diff.cpp14.lex]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L1603)
**Affected subclause:** [[lex.phases]](lex.phases)
**Change:** Removal of trigraph support as a required feature[.](#1.sentence-1)
**Rationale:** Prevents accidental uses of trigraphs in non-raw string literals and comments[.](#1.sentence-2)
**Effect on original feature:** Valid C++ 2014 code that uses trigraphs may not be valid or may have different
semantics in this revision of C++[.](#1.sentence-3)
Implementations may choose to
translate trigraphs as specified in C++ 2014 if they appear outside of a raw
string literal, as part of theimplementation-defined
mapping from input source file characters to
the translation character set[.](#1.sentence-4)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L1618)
**Affected subclause:** [[lex.ppnumber]](lex.ppnumber)
**Change:** [*pp-number*](lex.ppnumber#nt:pp-number "5.7Preprocessing numbers[lex.ppnumber]") can contain p [*sign*](lex.fcon#nt:sign "5.13.4Floating-point literals[lex.fcon]") andP [*sign*](lex.fcon#nt:sign "5.13.4Floating-point literals[lex.fcon]")[.](#2.sentence-1)
**Rationale:** Necessary to enable [*hexadecimal-floating-point-literal*](lex.fcon#nt:hexadecimal-floating-point-literal "5.13.4Floating-point literals[lex.fcon]")*s*[.](#2.sentence-2)
**Effect on original feature:** Valid C++ 2014 code may fail to compile or produce different results in
this revision of C++[.](#2.sentence-3)
Specifically, character sequences like 0p+0 and 0e1_p+0 are three separate tokens each in C++ 2014, but one single token
in this revision of C++[.](#2.sentence-4)
[*Example [1](#example-1)*: #define F(a) b ## aint b0p = F(0p+0); // ill-formed; equivalent to “int b0p = b0p + 0;'' in C++ 2014 — *end example*]

View File

@@ -0,0 +1,56 @@
[diff.cpp14.library]
# Annex C (informative) Compatibility [[diff]](./#diff)
## C.4 C++ and ISO C++ 2014 [[diff.cpp14]](diff.cpp14#library)
### C.4.8 [[library]](library "16Library introduction"): library introduction [diff.cpp14.library]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L1811)
**Affected subclause:** [[headers]](headers)
**Change:** New headers[.](#1.sentence-1)
**Rationale:** New functionality[.](#1.sentence-2)
**Effect on original feature:** The following C++ headers are new:[<any>](any.synop#header:%3cany%3e "22.7.2Header <any> synopsis[any.synop]"),[<charconv>](charconv.syn#header:%3ccharconv%3e "28.2.1Header <charconv> synopsis[charconv.syn]"),[<execution>](execution.syn#header:%3cexecution%3e "33.4Header <execution> synopsis[execution.syn]"),[<filesystem>](fs.filesystem.syn#header:%3cfilesystem%3e "31.12.4Header <filesystem> synopsis[fs.filesystem.syn]"),[<memory_resource>](mem.res.syn#header:%3cmemory_resource%3e "20.5.1Header <memory_­resource> synopsis[mem.res.syn]"),[<optional>](optional.syn#header:%3coptional%3e "22.5.2Header <optional> synopsis[optional.syn]"),
[<string_view>](string.view.synop#header:%3cstring_view%3e "27.3.2Header <string_­view> synopsis[string.view.synop]"),
and[<variant>](variant.syn#header:%3cvariant%3e "22.6.2Header <variant> synopsis[variant.syn]")[.](#1.sentence-4)
Valid C++ 2014 code that #includes headers with these names may be
invalid in this revision of C++[.](#1.sentence-5)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L1830)
**Affected subclause:** [[namespace.future]](namespace.future)
**Change:** New reserved namespaces[.](#2.sentence-1)
**Rationale:** Reserve namespaces for future revisions of the standard library
that might otherwise be incompatible with existing programs[.](#2.sentence-2)
**Effect on original feature:** The global namespaces std followed by an arbitrary sequence of [*digit*](lex.name#nt:digit "5.11Identifiers[lex.name]")*s* ([[lex.name]](lex.name "5.11Identifiers"))
are reserved for future standardization[.](#2.sentence-3)
Valid C++ 2014 code that uses such a top-level namespace,
e.g., std2, may be invalid in this revision of C++[.](#2.sentence-4)

View File

@@ -0,0 +1,35 @@
[diff.cpp14.string]
# Annex C (informative) Compatibility [[diff]](./#diff)
## C.4 C++ and ISO C++ 2014 [[diff.cpp14]](diff.cpp14#string)
### C.4.10 [[strings]](strings "27Strings library"): strings library [diff.cpp14.string]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L1875)
**Affected subclause:** [[basic.string]](basic.string)
**Change:** Non-const .data() member added[.](#1.sentence-1)
**Rationale:** The lack of a non-const .data() differed from the similar member of std::vector[.](#1.sentence-2)
This change regularizes behavior[.](#1.sentence-3)
**Effect on original feature:** Overloaded functions which have differing code paths
for char* and const char* arguments
will execute differently
when called with a non-const string's .data() member
in this revision of C++[.](#1.sentence-4)
[*Example [1](#example-1)*: int f(char *) = delete;int f(const char *);
string s;int x = f(s.data()); // ill-formed; previously well-formed — *end example*]

View File

@@ -0,0 +1,32 @@
[diff.cpp14.temp]
# Annex C (informative) Compatibility [[diff]](./#diff)
## C.4 C++ and ISO C++ 2014 [[diff.cpp14]](diff.cpp14#temp)
### C.4.6 [[temp]](temp "13Templates"): templates [diff.cpp14.temp]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L1764)
**Affected subclause:** [[temp.deduct.type]](temp.deduct.type)
**Change:** Allowance to deduce from the type of a constant template argument[.](#1.sentence-1)
**Rationale:** In combination with the ability to declare
constant template arguments with placeholder types,
allows partial specializations to decompose
from the type deduced for the constant template argument[.](#1.sentence-2)
**Effect on original feature:** Valid C++ 2014 code may fail to compile
or produce different results in this revision of C++[.](#1.sentence-3)
[*Example [1](#example-1)*: template <int N> struct A;template <typename T, T N> int foo(A<N> *) = delete;void foo(void *);void bar(A<0> *p) { foo(p); // ill-formed; previously well-formed} — *end example*]

View File

@@ -0,0 +1,55 @@
[diff.cpp14.utilities]
# Annex C (informative) Compatibility [[diff]](./#diff)
## C.4 C++ and ISO C++ 2014 [[diff.cpp14]](diff.cpp14#utilities)
### C.4.9 [[utilities]](utilities "22General utilities library"): general utilities library [diff.cpp14.utilities]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L1845)
**Affected subclause:** [[func.wrap]](func.wrap)
**Change:** Constructors taking allocators removed[.](#1.sentence-1)
**Rationale:** No implementation consensus[.](#1.sentence-2)
**Effect on original feature:** Valid C++ 2014 code may fail to compile or may change meaning in this
revision of C++[.](#1.sentence-3)
Specifically, constructing a std::function with
an allocator is ill-formed and uses-allocator construction will not pass an
allocator to std::function constructors in this revision of C++[.](#1.sentence-4)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L1856)
**Affected subclause:** [[util.smartptr.shared]](util.smartptr.shared)
**Change:** Different constraint on conversions from unique_ptr[.](#2.sentence-1)
**Rationale:** Adding array support to shared_ptr,
via the syntax shared_ptr<T[]> and shared_ptr<T[N]>[.](#2.sentence-2)
**Effect on original feature:** Valid C++ 2014 code may fail to compile or may change meaning in this
revision of C++[.](#2.sentence-3)
[*Example [1](#example-1)*: #include <memory> std::unique_ptr<int[]> arr(new int[1]);
std::shared_ptr<int> ptr(std::move(arr)); // error: int(*)[] is not compatible with int* — *end example*]

927
cppdraft/diff/cpp17.md Normal file
View File

@@ -0,0 +1,927 @@
[diff.cpp17]
# Annex C (informative) Compatibility [[diff]](./#diff)
## C.3 C++ and ISO C++ 2017 [diff.cpp17]
### [C.3.1](#general) General [[diff.cpp17.general]](diff.cpp17.general)
[1](#general-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L834)
Subclause [diff.cpp17] lists the differences between C++ and
ISO C++ 2017,
in addition to those listed above,
by the chapters of this document[.](#general-1.sentence-1)
### [C.3.2](#lex) [[lex]](lex "5Lexical conventions"): lexical conventions [[diff.cpp17.lex]](diff.cpp17.lex)
[1](#lex-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L843)
**Affected subclauses:** [[lex.pptoken]](lex.pptoken), [[module.unit]](module.unit), [[module.import]](module.import), [[cpp.pre]](cpp.pre), [[cpp.module]](cpp.module), and [[cpp.import]](cpp.import)
**Change:** New identifiers with special meaning[.](#lex-1.sentence-1)
**Rationale:** Required for new features[.](#lex-1.sentence-2)
**Effect on original feature:** Logical lines beginning withmodule or import may
be interpreted differently
in this revision of C++[.](#lex-1.sentence-3)
[*Example [1](#lex-example-1)*: class module {};module m1; // was variable declaration; now [*module-declaration*](module.unit#nt:module-declaration "10.1Module units and purviews[module.unit]")module *m2; // variable declarationclass import {};import j1; // was variable declaration; now [*module-import-declaration*](module.import#nt:module-import-declaration "10.3Import declaration[module.import]")::import j2; // variable declaration — *end example*]
[2](#lex-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L865)
**Affected subclause:** [[lex.header]](lex.header)
**Change:** [*header-name*](lex.header#nt:header-name "5.6Header names[lex.header]") tokens are formed in more contexts[.](#lex-2.sentence-1)
**Rationale:** Required for new features[.](#lex-2.sentence-2)
**Effect on original feature:** When the identifier import is followed by a < character,
a [*header-name*](lex.header#nt:header-name "5.6Header names[lex.header]") token may be formed[.](#lex-2.sentence-3)
[*Example [2](#lex-example-2)*: template<typename> class import {};import<int> f(); // ill-formed; previously well-formed::import<int> g(); // OK — *end example*]
[3](#lex-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L882)
**Affected subclause:** [[lex.key]](lex.key)
**Change:** New keywords[.](#lex-3.sentence-1)
**Rationale:** Required for new features[.](#lex-3.sentence-2)
- [(3.1)](#lex-3.1)
The char8_t keyword is added to differentiate
the types of ordinary and UTF-8 literals ([[lex.string]](lex.string "5.13.5String literals"))[.](#lex-3.1.sentence-1)
- [(3.2)](#lex-3.2)
The concept keyword is
added to enable the definition of concepts ([[temp.concept]](temp.concept "13.7.9Concept definitions"))[.](#lex-3.2.sentence-1)
- [(3.3)](#lex-3.3)
The consteval keyword is added to
declare immediate functions ([[dcl.constexpr]](dcl.constexpr "9.2.6The constexpr and consteval specifiers"))[.](#lex-3.3.sentence-1)
- [(3.4)](#lex-3.4)
The constinit keyword is added to
prevent unintended dynamic initialization ([[dcl.constinit]](dcl.constinit "9.2.7The constinit specifier"))[.](#lex-3.4.sentence-1)
- [(3.5)](#lex-3.5)
The co_await, co_yield, and co_return keywords are added
to enable the definition of coroutines ([[dcl.fct.def.coroutine]](dcl.fct.def.coroutine "9.6.4Coroutine definitions"))[.](#lex-3.5.sentence-1)
- [(3.6)](#lex-3.6)
The requires keyword is added
to introduce constraints through a [*requires-clause*](temp.pre#nt:requires-clause "13.1Preamble[temp.pre]") ([[temp.pre]](temp.pre "13.1Preamble"))
or a [*requires-expression*](expr.prim.req.general#nt:requires-expression "7.5.8.1General[expr.prim.req.general]") ([[expr.prim.req]](expr.prim.req "7.5.8Requires expressions"))[.](#lex-3.6.sentence-1)
**Effect on original feature:** Valid C++ 2017 code usingchar8_t,concept,consteval,constinit,co_await, co_yield, co_return,
or requires as an identifier is not valid in this revision of C++[.](#lex-3.sentence-3)
[4](#lex-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L919)
**Affected subclause:** [[lex.operators]](lex.operators)
**Change:** New operator <=>[.](#lex-4.sentence-1)
**Rationale:** Necessary for new functionality[.](#lex-4.sentence-2)
**Effect on original feature:** Valid C++ 2017 code that contains a <= token
immediately followed by a > token
may be ill-formed or have different semantics in this revision of C++[.](#lex-4.sentence-3)
[*Example [3](#lex-example-3)*: namespace N {struct X {}; bool operator<=(X, X); template<bool(X, X)> struct Y {};
Y<operator<=> y; // ill-formed; previously well-formed} — *end example*]
[5](#lex-5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L939)
**Affected subclause:** [[lex.literal]](lex.literal)
**Change:** Type of UTF-8 string and character literals[.](#lex-5.sentence-1)
**Rationale:** Required for new features[.](#lex-5.sentence-2)
The changed types enable function overloading, template specialization, and
type deduction to distinguish ordinary and UTF-8 string and character literals[.](#lex-5.sentence-3)
**Effect on original feature:** Valid C++ 2017 code that depends on
UTF-8 string literals having type “array of const char” and
UTF-8 character literals having type “char”
is not valid in this revision of C++[.](#lex-5.sentence-4)
[*Example [4](#lex-example-4)*: const auto *u8s = u8"text"; // u8s previously deduced as const char*; now deduced as const char8_t*const char *ps = u8s; // ill-formed; previously well-formedauto u8c = u8'c'; // u8c previously deduced as char; now deduced as char8_tchar *pc = &u8c; // ill-formed; previously well-formed std::string s = u8"text"; // ill-formed; previously well-formedvoid f(const char *s);
f(u8"text"); // ill-formed; previously well-formedtemplate<typename> struct ct;template<> struct ct<char> {using type = char;};
ct<decltype(u8'c')>::type x; // ill-formed; previously well-formed. — *end example*]
### [C.3.3](#basic) [[basic]](basic "6Basics"): basics [[diff.cpp17.basic]](diff.cpp17.basic)
[1](#basic-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L975)
**Affected subclause:** [[basic.life]](basic.life)
**Change:** A pseudo-destructor call ends the lifetime of
the object to which it is applied[.](#basic-1.sentence-1)
**Rationale:** Increase consistency of the language model[.](#basic-1.sentence-2)
**Effect on original feature:** Valid ISO C++ 2017 code may be ill-formed or
have undefined behavior in this revision of C++[.](#basic-1.sentence-3)
[*Example [1](#basic-example-1)*: int f() {int a = 123; using T = int;
a.~T(); return a; // undefined behavior; previously returned 123} — *end example*]
[2](#basic-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L995)
**Affected subclause:** [[intro.races]](intro.races)
**Change:** Except for the initial release operation,
a release sequence consists solely of atomic read-modify-write operations[.](#basic-2.sentence-1)
**Rationale:** Removal of rarely used and confusing feature[.](#basic-2.sentence-2)
**Effect on original feature:** If a memory_order_release atomic store is followed
by a memory_order_relaxed store to the same variable by the same thread,
then reading the latter value with a memory_order_acquire load
no longer provides any “happens before” guarantees,
even in the absence of intervening stores by another thread[.](#basic-2.sentence-3)
### [C.3.4](#expr) [[expr]](expr "7Expressions"): expressions [[diff.cpp17.expr]](diff.cpp17.expr)
[1](#expr-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L1010)
**Affected subclause:** [[expr.prim.lambda.capture]](expr.prim.lambda.capture)
**Change:** Implicit lambda capture may capture additional entities[.](#expr-1.sentence-1)
**Rationale:** Rule simplification, necessary to resolve interactions with constexpr if[.](#expr-1.sentence-2)
**Effect on original feature:** Lambdas with a [*capture-default*](expr.prim.lambda.capture#nt:capture-default "7.5.6.3Captures[expr.prim.lambda.capture]") may capture local entities
that were not captured in C++ 2017
if those entities are only referenced in contexts
that do not result in an odr-use[.](#expr-1.sentence-3)
### [C.3.5](#dcl.dcl) [[dcl]](dcl "9Declarations"): declarations [[diff.cpp17.dcl.dcl]](diff.cpp17.dcl.dcl)
[1](#dcl.dcl-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L1024)
**Affected subclause:** [[dcl.typedef]](dcl.typedef)
**Change:** Unnamed classes with a typedef name for linkage purposes
can contain only C-compatible constructs[.](#dcl.dcl-1.sentence-1)
**Rationale:** Necessary for implementability[.](#dcl.dcl-1.sentence-2)
**Effect on original feature:** Valid C++ 2017 code may be ill-formed in this revision of C++[.](#dcl.dcl-1.sentence-3)
[*Example [1](#dcl.dcl-example-1)*: typedef struct {void f() {} // ill-formed; previously well-formed} S; — *end example*]
[2](#dcl.dcl-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L1040)
**Affected subclause:** [[dcl.fct.default]](dcl.fct.default)
**Change:** A function cannot have different default arguments
in different translation units[.](#dcl.dcl-2.sentence-1)
**Rationale:** Required for modules support[.](#dcl.dcl-2.sentence-2)
**Effect on original feature:** Valid C++ 2017 code may be ill-formed in this revision of C++,
with no diagnostic required[.](#dcl.dcl-2.sentence-3)
[*Example [2](#dcl.dcl-example-2)*: // Translation unit 1int f(int a = 42);int g() { return f(); }// Translation unit 2int f(int a = 76) { return a; } // ill-formed, no diagnostic required; previously well-formedint g();int main() { return g(); } // used to return 42 — *end example*]
[3](#dcl.dcl-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L1062)
**Affected subclause:** [[dcl.init.aggr]](dcl.init.aggr)
**Change:** A class that has user-declared constructors is never an aggregate[.](#dcl.dcl-3.sentence-1)
**Rationale:** Remove potentially error-prone aggregate initialization
which may apply notwithstanding the declared constructors of a class[.](#dcl.dcl-3.sentence-2)
**Effect on original feature:** Valid C++ 2017 code that aggregate-initializes
a type with a user-declared constructor
may be ill-formed or have different semantics
in this revision of C++[.](#dcl.dcl-3.sentence-3)
[*Example [3](#dcl.dcl-example-3)*: struct A { // not an aggregate; previously an aggregate A() = delete;};
struct B { // not an aggregate; previously an aggregate B() = default; int i = 0;};
struct C { // not an aggregate; previously an aggregate C(C&&) = default; int a, b;};
A a{}; // ill-formed; previously well-formed B b = {1}; // ill-formed; previously well-formedauto* c = new C{2, 3}; // ill-formed; previously well-formedstruct Y;
struct X {operator Y();};
struct Y { // not an aggregate; previously an aggregate Y(const Y&) = default;
X x;};
Y y{X{}}; // copy constructor call; previously aggregate-initialization — *end example*]
[4](#dcl.dcl-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L1108)
**Affected subclause:** [[dcl.init.list]](dcl.init.list)
**Change:** Boolean conversion from a pointer or pointer-to-member type
is now a narrowing conversion[.](#dcl.dcl-4.sentence-1)
**Rationale:** Catches bugs[.](#dcl.dcl-4.sentence-2)
**Effect on original feature:** Valid C++ 2017 code may fail to compile
in this revision of C++[.](#dcl.dcl-4.sentence-3)
[*Example [4](#dcl.dcl-example-4)*: bool y[] = { "bc" }; // ill-formed; previously well-formed — *end example*]
### [C.3.6](#class) [[class]](class "11Classes"): classes [[diff.cpp17.class]](diff.cpp17.class)
[1](#class-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L1125)
**Affected subclauses:** [[class.ctor]](class.ctor) and [[class.conv.fct]](class.conv.fct)
**Change:** The class name can no longer be used parenthesized
immediately after an explicit [*decl-specifier*](dcl.spec.general#nt:decl-specifier "9.2.1General[dcl.spec.general]") in a constructor declaration[.](#class-1.sentence-1)
The [*conversion-function-id*](class.conv.fct#nt:conversion-function-id "11.4.8.3Conversion functions[class.conv.fct]") can no longer be used parenthesized
immediately after an explicit [*decl-specifier*](dcl.spec.general#nt:decl-specifier "9.2.1General[dcl.spec.general]") in a conversion function declaration[.](#class-1.sentence-2)
**Rationale:** Necessary for new functionality[.](#class-1.sentence-3)
**Effect on original feature:** Valid C++ 2017 code may fail to compile
in this revision of C++[.](#class-1.sentence-4)
[*Example [1](#class-example-1)*: struct S {explicit (S)(const S&); // ill-formed; previously well-formedexplicit (operator int)(); // ill-formed; previously well-formedexplicit(true) (S)(int); // OK}; — *end example*]
[2](#class-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L1148)
**Affected subclauses:** [[class.ctor]](class.ctor) and [[class.dtor]](class.dtor)
**Change:** A [*simple-template-id*](temp.names#nt:simple-template-id "13.3Names of template specializations[temp.names]") is no longer valid as the [*declarator-id*](dcl.decl.general#nt:declarator-id "9.3.1General[dcl.decl.general]") of a constructor or destructor[.](#class-2.sentence-1)
**Rationale:** Remove potentially error-prone option for redundancy[.](#class-2.sentence-2)
**Effect on original feature:** Valid C++ 2017 code may fail to compile
in this revision of C++[.](#class-2.sentence-3)
[*Example [2](#class-example-2)*: template<class T>struct A { A<T>(); // error: [*simple-template-id*](temp.names#nt:simple-template-id "13.3Names of template specializations[temp.names]") not allowed for constructor A(int); // OK, injected-class-name used~A<T>(); // error: [*simple-template-id*](temp.names#nt:simple-template-id "13.3Names of template specializations[temp.names]") not allowed for destructor}; — *end example*]
[3](#class-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L1168)
**Affected subclause:** [[class.copy.elision]](class.copy.elision)
**Change:** A function returning an implicitly movable entity
may invoke a constructor taking an rvalue reference to a type
different from that of the returned expression[.](#class-3.sentence-1)
Function and catch-clause parameters can be thrown using move constructors[.](#class-3.sentence-2)
**Rationale:** Side effect of making it easier to write
more efficient code that takes advantage of moves[.](#class-3.sentence-3)
**Effect on original feature:** Valid C++ 2017 code may fail to compile or have different semantics
in this revision of C++[.](#class-3.sentence-4)
[*Example [3](#class-example-3)*: struct base { base();
base(base const &);private: base(base &&);};
struct derived : base {};
base f(base b) {throw b; // error: base(base &&) is private derived d; return d; // error: base(base &&) is private}struct S { S(const char *s) : m(s) { } S(const S&) = default;
S(S&& other) : m(other.m) { other.m = nullptr; }const char * m;};
S consume(S&& s) { return s; }void g() { S s("text");
consume(static_cast<S&&>(s)); char c = *s.m; // undefined behavior; previously ok} — *end example*]
### [C.3.7](#over) [[over]](over "12Overloading"): overloading [[diff.cpp17.over]](diff.cpp17.over)
[1](#over-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L1216)
**Affected subclause:** [[over.match.oper]](over.match.oper)
**Change:** Equality and inequality expressions can now find
reversed and rewritten candidates[.](#over-1.sentence-1)
**Rationale:** Improve consistency of equality with three-way comparison
and make it easier to write the full complement of equality operations[.](#over-1.sentence-2)
**Effect on original feature:** For certain pairs of types where one is convertible to the other,
equality or inequality expressions between an object of one type
and an object of the other type invoke a different operator[.](#over-1.sentence-3)
Also, for certain types, equality or inequality expressions
between two objects of that type become ambiguous[.](#over-1.sentence-4)
[*Example [1](#over-example-1)*: struct A {operator int() const;};
bool operator==(A, int); // #1// #2 is built-in candidate: bool operator==(int, int);// #3 is built-in candidate: bool operator!=(int, int);int check(A x, A y) {return (x == y) + // ill-formed; previously well-formed(10 == x) + // calls #1, previously selected #2(10 != x); // calls #1, previously selected #3} — *end example*]
[2](#over-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L1247)
**Affected subclause:** [[over.match.oper]](over.match.oper)
**Change:** Overload resolution may change for equality operators ([[expr.eq]](expr.eq "7.6.10Equality operators"))[.](#over-2.sentence-1)
**Rationale:** Support calling operator== with reversed order of arguments[.](#over-2.sentence-2)
**Effect on original feature:** Valid C++ 2017 code that uses equality operators with conversion functions
may be ill-formed or have different semantics in this revision of C++[.](#over-2.sentence-3)
[*Example [2](#over-example-2)*: struct A {operator int() const { return 10; }};
bool operator==(A, int); // #1// #2 is built-in candidate: bool operator==(int, int);bool b = 10 == A(); // calls #1 with reversed order of arguments; previously selected #2struct B {bool operator==(const B&); // member function with no cv-qualifier};
B b1;bool eq = (b1 == b1); // ambiguous; previously well-formed — *end example*]
### [C.3.8](#temp) [[temp]](temp "13Templates"): templates [[diff.cpp17.temp]](diff.cpp17.temp)
[1](#temp-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L1275)
**Affected subclause:** [[temp.names]](temp.names)
**Change:** An [*unqualified-id*](expr.prim.id.unqual#nt:unqualified-id "7.5.5.2Unqualified names[expr.prim.id.unqual]") that is followed by a < and for which name lookup
finds nothing or finds a function
will be treated as a [*template-name*](temp.names#nt:template-name "13.3Names of template specializations[temp.names]") in order to potentially cause argument-dependent lookup to be performed[.](#temp-1.sentence-1)
**Rationale:** It was problematic to call a function template
with an explicit template argument list
via argument-dependent lookup
because of the need to have a template with the same name
visible via normal lookup[.](#temp-1.sentence-2)
**Effect on original feature:** Previously valid code that uses a function name
as the left operand of a < operator
would become ill-formed[.](#temp-1.sentence-3)
[*Example [1](#temp-example-1)*: struct A {};bool operator<(void (*fp)(), A);void f() {}int main() { A a;
f < a; // ill-formed; previously well-formed(f) < a; // still well-formed} — *end example*]
### [C.3.9](#except) [[except]](except "14Exception handling"): exception handling [[diff.cpp17.except]](diff.cpp17.except)
[1](#except-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L1308)
**Affected subclause:** [[except.spec]](except.spec)
**Change:** Remove throw() exception specification[.](#except-1.sentence-1)
**Rationale:** Removal of obsolete feature that has been replaced by noexcept[.](#except-1.sentence-2)
**Effect on original feature:** A valid C++ 2017 function declaration, member function declaration, function
pointer declaration, or function reference declaration that uses throw() for its exception specification will be rejected as ill-formed in this
revision of C++[.](#except-1.sentence-3)
It should simply be replaced with noexcept for no
change of meaning since C++ 2017[.](#except-1.sentence-4)
[*Note [1](#except-note-1)*:
There is no way to write a function declaration
that is non-throwing in this revision of C++
and is also non-throwing in C++ 2003
except by using the preprocessor to generate
a different token sequence in each case[.](#except-1.sentence-5)
— *end note*]
### [C.3.10](#library) [[library]](library "16Library introduction"): library introduction [[diff.cpp17.library]](diff.cpp17.library)
[1](#library-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L1329)
**Affected subclause:** [[headers]](headers)
**Change:** New headers[.](#library-1.sentence-1)
**Rationale:** New functionality[.](#library-1.sentence-2)
**Effect on original feature:** The following C++ headers are new:[<barrier>](barrier.syn#header:%3cbarrier%3e "32.9.3.2Header <barrier> synopsis[barrier.syn]"),[<bit>](bit.general#header:%3cbit%3e "22.11.1General[bit.general]"),[<charconv>](charconv.syn#header:%3ccharconv%3e "28.2.1Header <charconv> synopsis[charconv.syn]"),[<compare>](compare.syn#header:%3ccompare%3e "17.12.1Header <compare> synopsis[compare.syn]"),[<concepts>](concepts.syn#header:%3cconcepts%3e "18.3Header <concepts> synopsis[concepts.syn]"),[<coroutine>](coroutine.syn#header:%3ccoroutine%3e "17.13.2Header <coroutine> synopsis[coroutine.syn]"),[<format>](format.formatter.spec#header:%3cformat%3e "28.5.6.4Formatter specializations[format.formatter.spec]"),[<latch>](latch.syn#header:%3clatch%3e "32.9.2.2Header <latch> synopsis[latch.syn]"),[<numbers>](numbers.syn#header:%3cnumbers%3e "29.8.1Header <numbers> synopsis[numbers.syn]"),[<ranges>](ranges.syn#header:%3cranges%3e "25.2Header <ranges> synopsis[ranges.syn]"),[<semaphore>](semaphore.syn#header:%3csemaphore%3e "32.8.2Header <semaphore> synopsis[semaphore.syn]"),[<source_location>](source.location.syn#header:%3csource_location%3e "17.8.1Header <source_­location> synopsis[source.location.syn]"),[<span>](span.syn#header:%3cspan%3e "23.7.2.1Header <span> synopsis[span.syn]"),[<stop_token>](thread.stoptoken.syn#header:%3cstop_token%3e "32.3.2Header <stop_­token> synopsis[thread.stoptoken.syn]"),[<syncstream>](syncstream.syn#header:%3csyncstream%3e "31.11.1Header <syncstream> synopsis[syncstream.syn]"), and[<version>](version.syn#header:%3cversion%3e "17.3.2Header <version> synopsis[version.syn]")[.](#library-1.sentence-3)
Valid C++ 2017 code that #includes headers with these names may be
invalid in this revision of C++[.](#library-1.sentence-4)
[2](#library-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L1355)
**Affected subclause:** [[headers]](headers)
**Change:** Remove vacuous C++ header files[.](#library-2.sentence-1)
**Rationale:** The empty headers implied a false requirement to achieve C compatibility with the C++ headers[.](#library-2.sentence-2)
**Effect on original feature:** A valid C++ 2017 program that #includes any of the following headers may fail to compile:<ccomplex>,<ciso646>,<cstdalign>,<cstdbool>, and<ctgmath>[.](#library-2.sentence-3)
To retain the same behavior:
- [(2.1)](#library-2.1)
a #include of <ccomplex> can be replaced by
a #include of [<complex>](complex.syn#header:%3ccomplex%3e "29.4.2Header <complex> synopsis[complex.syn]"),
- [(2.2)](#library-2.2)
a #include of <ctgmath> can be replaced by
a #include of [<cmath>](cmath.syn#header:%3ccmath%3e "29.7.1Header <cmath> synopsis[cmath.syn]") and
a #include of [<complex>](complex.syn#header:%3ccomplex%3e "29.4.2Header <complex> synopsis[complex.syn]"),
and
- [(2.3)](#library-2.3)
a #include of<ciso646>,<cstdalign>, or<cstdbool> can simply be removed[.](#library-2.sentence-4)
### [C.3.11](#containers) [[containers]](containers "23Containers library"): containers library [[diff.cpp17.containers]](diff.cpp17.containers)
[1](#containers-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L1387)
**Affected subclauses:** [[forward.list]](forward.list) and [[list]](list)
**Change:** Return types of remove, remove_if, and unique changed from void to container::size_type[.](#containers-1.sentence-1)
**Rationale:** Improve efficiency and convenience of finding number of removed elements[.](#containers-1.sentence-2)
**Effect on original feature:** Code that depends on the return types might have different semantics in this revision of C++[.](#containers-1.sentence-3)
Translation units compiled against this version of C++ may be incompatible with
translation units compiled against C++ 2017, either failing to link or having undefined behavior[.](#containers-1.sentence-4)
### [C.3.12](#iterators) [[iterators]](iterators "24Iterators library"): iterators library [[diff.cpp17.iterators]](diff.cpp17.iterators)
[1](#iterators-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L1400)
**Affected subclause:** [[iterator.traits]](iterator.traits)
**Change:** The specialization of iterator_traits for void* and
for function pointer types no longer contains any nested typedefs[.](#iterators-1.sentence-1)
**Rationale:** Corrects an issue misidentifying pointer types that are not incrementable
as iterator types[.](#iterators-1.sentence-2)
**Effect on original feature:** A valid C++ 2017 program that relies on the presence of the typedefs
may fail to compile, or have different behavior[.](#iterators-1.sentence-3)
### [C.3.13](#alg.reqs) [[algorithms]](algorithms "26Algorithms library"): algorithms library [[diff.cpp17.alg.reqs]](diff.cpp17.alg.reqs)
[1](#alg.reqs-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L1413)
**Affected subclause:** [[algorithms.requirements]](algorithms.requirements)
**Change:** The number and order of deducible template parameters for algorithm declarations
is now unspecified, instead of being as-declared[.](#alg.reqs-1.sentence-1)
**Rationale:** Increase implementor freedom and allow some function templates
to be implemented as function objects with templated call operators[.](#alg.reqs-1.sentence-2)
**Effect on original feature:** A valid C++ 2017 program that passes explicit template arguments to
algorithms not explicitly specified to allow such in this version of C++
may fail to compile or have undefined behavior[.](#alg.reqs-1.sentence-3)
### [C.3.14](#input.output) [[input.output]](input.output "31Input/output library"): input/output library [[diff.cpp17.input.output]](diff.cpp17.input.output)
[1](#input.output-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L1427)
**Affected subclause:** [[istream.extractors]](istream.extractors)
**Change:** Character array extraction only takes array types[.](#input.output-1.sentence-1)
**Rationale:** Increase safety via preventing buffer overflow at compile time[.](#input.output-1.sentence-2)
**Effect on original feature:** Valid C++ 2017 code may fail to compile in this revision of C++[.](#input.output-1.sentence-3)
[*Example [1](#input.output-example-1)*: auto p = new char[100];char q[100];
std::cin >> std::setw(20) >> p; // ill-formed; previously well-formed std::cin >> std::setw(20) >> q; // OK — *end example*]
[2](#input.output-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L1443)
**Affected subclause:** [[ostream.inserters.character]](ostream.inserters.character)
**Change:** Overload resolution for ostream inserters used with UTF-8 literals[.](#input.output-2.sentence-1)
**Rationale:** Required for new features[.](#input.output-2.sentence-2)
**Effect on original feature:** Valid C++ 2017 code that passes UTF-8 literals tobasic_ostream<char, ...>::operator<< orbasic_ostream<wchar_t, ...>::operator<< is now ill-formed[.](#input.output-2.sentence-3)
[*Example [2](#input.output-example-2)*: std::cout << u8"text"; // previously called operator<<(const char*) and printed a string;// now ill-formed std::cout << u8'X'; // previously called operator<<(char) and printed a character;// now ill-formed — *end example*]
[3](#input.output-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L1462)
**Affected subclause:** [[ostream.inserters.character]](ostream.inserters.character)
**Change:** Overload resolution for ostream inserters
used with wchar_t, char16_t, or char32_t types[.](#input.output-3.sentence-1)
**Rationale:** Removal of surprising behavior[.](#input.output-3.sentence-2)
**Effect on original feature:** Valid C++ 2017 code that passeswchar_t, char16_t, or char32_t characters or strings
to basic_ostream<char, ...>::operator<< or
that passes char16_t or char32_t characters or strings
to basic_ostream<wchar_t, ...>::operator<< is now ill-formed[.](#input.output-3.sentence-3)
[*Example [3](#input.output-example-3)*: std::cout << u"text"; // previously formatted the string as a pointer value;// now ill-formed std::cout << u'X'; // previously formatted the character as an integer value;// now ill-formed — *end example*]
[4](#input.output-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L1483)
**Affected subclause:** [[fs.class.path]](fs.class.path)
**Change:** Return type of filesystem path format observer member functions[.](#input.output-4.sentence-1)
**Rationale:** Required for new features[.](#input.output-4.sentence-2)
**Effect on original feature:** Valid C++ 2017 code that depends on the u8string() andgeneric_u8string() member functions of std::filesystem::path returning std::string is not valid in this revision of C++[.](#input.output-4.sentence-3)
[*Example [4](#input.output-example-4)*: std::filesystem::path p;
std::string s1 = p.u8string(); // ill-formed; previously well-formed std::string s2 = p.generic_u8string(); // ill-formed; previously well-formed — *end example*]
### [C.3.15](#depr) [[depr]](depr "Annex D(normative)Compatibility features"): compatibility features [[diff.cpp17.depr]](diff.cpp17.depr)
[1](#depr-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L1503)
**Change:** Remove uncaught_exception[.](#depr-1.sentence-1)
**Rationale:** The function did not have a clear specification when multiple exceptions were
active, and has been superseded by uncaught_exceptions[.](#depr-1.sentence-2)
**Effect on original feature:** A valid C++ 2017 program that calls std::uncaught_exception may fail
to compile[.](#depr-1.sentence-3)
It can be revised to use std::uncaught_exceptions instead,
for clear and portable semantics[.](#depr-1.sentence-4)
[2](#depr-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L1514)
**Change:** Remove support for adaptable function API[.](#depr-2.sentence-1)
**Rationale:** The deprecated support relied on a limited convention that could not be
extended to support the general case or new language features[.](#depr-2.sentence-2)
It has been
superseded by direct language support with decltype, and by thestd::bind and std::not_fn function templates[.](#depr-2.sentence-3)
**Effect on original feature:** A valid C++ 2017 program that relies on the presence of result_type,argument_type, first_argument_type, orsecond_argument_type in a standard library class may fail to compile[.](#depr-2.sentence-4)
A
valid C++ 2017 program that calls not1 or not2, or uses the
class templates unary_negate or binary_negate, may fail to
compile[.](#depr-2.sentence-5)
[3](#depr-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L1530)
**Change:** Remove redundant members from std::allocator[.](#depr-3.sentence-1)
**Rationale:** std::allocator was overspecified, encouraging direct usage in user containers
rather than relying on std::allocator_traits, leading to poor containers[.](#depr-3.sentence-2)
**Effect on original feature:** A valid C++ 2017 program that directly makes use of the pointer,const_pointer, reference, const_reference,rebind, address, construct, destroy, ormax_size members of std::allocator, or that directly callsallocate with an additional hint argument, may fail to compile[.](#depr-3.sentence-3)
[4](#depr-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L1543)
**Change:** Remove raw_storage_iterator[.](#depr-4.sentence-1)
**Rationale:** The iterator encouraged use of potentially-throwing algorithms, but did
not return the number of elements successfully constructed,
as would be necessary to destroy them[.](#depr-4.sentence-2)
**Effect on original feature:** A valid C++ 2017 program that uses this iterator class may fail to compile[.](#depr-4.sentence-3)
[5](#depr-5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L1553)
**Change:** Remove temporary buffers API[.](#depr-5.sentence-1)
**Rationale:** The temporary buffer facility was intended to provide an efficient optimization
for small memory requests, but there is little evidence this was achieved in
practice, while requiring the user to provide their own exception-safe wrappers
to guard use of the facility in many cases[.](#depr-5.sentence-2)
**Effect on original feature:** A valid C++ 2017 program that calls get_temporary_buffer orreturn_temporary_buffer may fail to compile[.](#depr-5.sentence-3)
[6](#depr-6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L1565)
**Change:** Remove shared_ptr::unique[.](#depr-6.sentence-1)
**Rationale:** The result of a call to this member function is not reliable in the presence of
multiple threads and weak pointers[.](#depr-6.sentence-2)
The member function use_count is
similarly unreliable, but has a clearer contract in such cases, and remains
available for well-defined use in single-threaded cases[.](#depr-6.sentence-3)
**Effect on original feature:** A valid C++ 2017 program that calls unique on a shared_ptr object may fail to compile[.](#depr-6.sentence-4)
[7](#depr-7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L1576)
**Affected subclause:** [[depr.meta.types]](depr.meta.types)
**Change:** Remove deprecated type traits[.](#depr-7.sentence-1)
**Rationale:** The traits had unreliable or awkward interfaces[.](#depr-7.sentence-2)
The is_literal_type trait provided no way to detect which subset of constructors and member
functions of a type were declared constexpr[.](#depr-7.sentence-3)
The result_of trait had a surprising syntax that did not directly support function types[.](#depr-7.sentence-4)
It has been superseded by the invoke_result trait[.](#depr-7.sentence-5)
**Effect on original feature:** A valid C++ 2017 program that relies on the is_literal_type orresult_of type traits, on the is_literal_type_v variable template,
or on the result_of_t alias template may fail to compile[.](#depr-7.sentence-6)

View File

@@ -0,0 +1,30 @@
[diff.cpp17.alg.reqs]
# Annex C (informative) Compatibility [[diff]](./#diff)
## C.3 C++ and ISO C++ 2017 [[diff.cpp17]](diff.cpp17#alg.reqs)
### C.3.13 [[algorithms]](algorithms "26Algorithms library"): algorithms library [diff.cpp17.alg.reqs]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L1413)
**Affected subclause:** [[algorithms.requirements]](algorithms.requirements)
**Change:** The number and order of deducible template parameters for algorithm declarations
is now unspecified, instead of being as-declared[.](#1.sentence-1)
**Rationale:** Increase implementor freedom and allow some function templates
to be implemented as function objects with templated call operators[.](#1.sentence-2)
**Effect on original feature:** A valid C++ 2017 program that passes explicit template arguments to
algorithms not explicitly specified to allow such in this version of C++
may fail to compile or have undefined behavior[.](#1.sentence-3)

View File

@@ -0,0 +1,55 @@
[diff.cpp17.basic]
# Annex C (informative) Compatibility [[diff]](./#diff)
## C.3 C++ and ISO C++ 2017 [[diff.cpp17]](diff.cpp17#basic)
### C.3.3 [[basic]](basic "6Basics"): basics [diff.cpp17.basic]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L975)
**Affected subclause:** [[basic.life]](basic.life)
**Change:** A pseudo-destructor call ends the lifetime of
the object to which it is applied[.](#1.sentence-1)
**Rationale:** Increase consistency of the language model[.](#1.sentence-2)
**Effect on original feature:** Valid ISO C++ 2017 code may be ill-formed or
have undefined behavior in this revision of C++[.](#1.sentence-3)
[*Example [1](#example-1)*: int f() {int a = 123; using T = int;
a.~T(); return a; // undefined behavior; previously returned 123} — *end example*]
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L995)
**Affected subclause:** [[intro.races]](intro.races)
**Change:** Except for the initial release operation,
a release sequence consists solely of atomic read-modify-write operations[.](#2.sentence-1)
**Rationale:** Removal of rarely used and confusing feature[.](#2.sentence-2)
**Effect on original feature:** If a memory_order_release atomic store is followed
by a memory_order_relaxed store to the same variable by the same thread,
then reading the latter value with a memory_order_acquire load
no longer provides any “happens before” guarantees,
even in the absence of intervening stores by another thread[.](#2.sentence-3)

View File

@@ -0,0 +1,91 @@
[diff.cpp17.class]
# Annex C (informative) Compatibility [[diff]](./#diff)
## C.3 C++ and ISO C++ 2017 [[diff.cpp17]](diff.cpp17#class)
### C.3.6 [[class]](class "11Classes"): classes [diff.cpp17.class]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L1125)
**Affected subclauses:** [[class.ctor]](class.ctor) and [[class.conv.fct]](class.conv.fct)
**Change:** The class name can no longer be used parenthesized
immediately after an explicit [*decl-specifier*](dcl.spec.general#nt:decl-specifier "9.2.1General[dcl.spec.general]") in a constructor declaration[.](#1.sentence-1)
The [*conversion-function-id*](class.conv.fct#nt:conversion-function-id "11.4.8.3Conversion functions[class.conv.fct]") can no longer be used parenthesized
immediately after an explicit [*decl-specifier*](dcl.spec.general#nt:decl-specifier "9.2.1General[dcl.spec.general]") in a conversion function declaration[.](#1.sentence-2)
**Rationale:** Necessary for new functionality[.](#1.sentence-3)
**Effect on original feature:** Valid C++ 2017 code may fail to compile
in this revision of C++[.](#1.sentence-4)
[*Example [1](#example-1)*: struct S {explicit (S)(const S&); // ill-formed; previously well-formedexplicit (operator int)(); // ill-formed; previously well-formedexplicit(true) (S)(int); // OK}; — *end example*]
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L1148)
**Affected subclauses:** [[class.ctor]](class.ctor) and [[class.dtor]](class.dtor)
**Change:** A [*simple-template-id*](temp.names#nt:simple-template-id "13.3Names of template specializations[temp.names]") is no longer valid as the [*declarator-id*](dcl.decl.general#nt:declarator-id "9.3.1General[dcl.decl.general]") of a constructor or destructor[.](#2.sentence-1)
**Rationale:** Remove potentially error-prone option for redundancy[.](#2.sentence-2)
**Effect on original feature:** Valid C++ 2017 code may fail to compile
in this revision of C++[.](#2.sentence-3)
[*Example [2](#example-2)*: template<class T>struct A { A<T>(); // error: [*simple-template-id*](temp.names#nt:simple-template-id "13.3Names of template specializations[temp.names]") not allowed for constructor A(int); // OK, injected-class-name used~A<T>(); // error: [*simple-template-id*](temp.names#nt:simple-template-id "13.3Names of template specializations[temp.names]") not allowed for destructor}; — *end example*]
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L1168)
**Affected subclause:** [[class.copy.elision]](class.copy.elision)
**Change:** A function returning an implicitly movable entity
may invoke a constructor taking an rvalue reference to a type
different from that of the returned expression[.](#3.sentence-1)
Function and catch-clause parameters can be thrown using move constructors[.](#3.sentence-2)
**Rationale:** Side effect of making it easier to write
more efficient code that takes advantage of moves[.](#3.sentence-3)
**Effect on original feature:** Valid C++ 2017 code may fail to compile or have different semantics
in this revision of C++[.](#3.sentence-4)
[*Example [3](#example-3)*: struct base { base();
base(base const &);private: base(base &&);};
struct derived : base {};
base f(base b) {throw b; // error: base(base &&) is private derived d; return d; // error: base(base &&) is private}struct S { S(const char *s) : m(s) { } S(const S&) = default;
S(S&& other) : m(other.m) { other.m = nullptr; }const char * m;};
S consume(S&& s) { return s; }void g() { S s("text");
consume(static_cast<S&&>(s)); char c = *s.m; // undefined behavior; previously ok} — *end example*]

View File

@@ -0,0 +1,29 @@
[diff.cpp17.containers]
# Annex C (informative) Compatibility [[diff]](./#diff)
## C.3 C++ and ISO C++ 2017 [[diff.cpp17]](diff.cpp17#containers)
### C.3.11 [[containers]](containers "23Containers library"): containers library [diff.cpp17.containers]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L1387)
**Affected subclauses:** [[forward.list]](forward.list) and [[list]](list)
**Change:** Return types of remove, remove_if, and unique changed from void to container::size_type[.](#1.sentence-1)
**Rationale:** Improve efficiency and convenience of finding number of removed elements[.](#1.sentence-2)
**Effect on original feature:** Code that depends on the return types might have different semantics in this revision of C++[.](#1.sentence-3)
Translation units compiled against this version of C++ may be incompatible with
translation units compiled against C++ 2017, either failing to link or having undefined behavior[.](#1.sentence-4)

View File

@@ -0,0 +1,113 @@
[diff.cpp17.dcl.dcl]
# Annex C (informative) Compatibility [[diff]](./#diff)
## C.3 C++ and ISO C++ 2017 [[diff.cpp17]](diff.cpp17#dcl.dcl)
### C.3.5 [[dcl]](dcl "9Declarations"): declarations [diff.cpp17.dcl.dcl]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L1024)
**Affected subclause:** [[dcl.typedef]](dcl.typedef)
**Change:** Unnamed classes with a typedef name for linkage purposes
can contain only C-compatible constructs[.](#1.sentence-1)
**Rationale:** Necessary for implementability[.](#1.sentence-2)
**Effect on original feature:** Valid C++ 2017 code may be ill-formed in this revision of C++[.](#1.sentence-3)
[*Example [1](#example-1)*: typedef struct {void f() {} // ill-formed; previously well-formed} S; — *end example*]
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L1040)
**Affected subclause:** [[dcl.fct.default]](dcl.fct.default)
**Change:** A function cannot have different default arguments
in different translation units[.](#2.sentence-1)
**Rationale:** Required for modules support[.](#2.sentence-2)
**Effect on original feature:** Valid C++ 2017 code may be ill-formed in this revision of C++,
with no diagnostic required[.](#2.sentence-3)
[*Example [2](#example-2)*: // Translation unit 1int f(int a = 42);int g() { return f(); }// Translation unit 2int f(int a = 76) { return a; } // ill-formed, no diagnostic required; previously well-formedint g();int main() { return g(); } // used to return 42 — *end example*]
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L1062)
**Affected subclause:** [[dcl.init.aggr]](dcl.init.aggr)
**Change:** A class that has user-declared constructors is never an aggregate[.](#3.sentence-1)
**Rationale:** Remove potentially error-prone aggregate initialization
which may apply notwithstanding the declared constructors of a class[.](#3.sentence-2)
**Effect on original feature:** Valid C++ 2017 code that aggregate-initializes
a type with a user-declared constructor
may be ill-formed or have different semantics
in this revision of C++[.](#3.sentence-3)
[*Example [3](#example-3)*: struct A { // not an aggregate; previously an aggregate A() = delete;};
struct B { // not an aggregate; previously an aggregate B() = default; int i = 0;};
struct C { // not an aggregate; previously an aggregate C(C&&) = default; int a, b;};
A a{}; // ill-formed; previously well-formed B b = {1}; // ill-formed; previously well-formedauto* c = new C{2, 3}; // ill-formed; previously well-formedstruct Y;
struct X {operator Y();};
struct Y { // not an aggregate; previously an aggregate Y(const Y&) = default;
X x;};
Y y{X{}}; // copy constructor call; previously aggregate-initialization — *end example*]
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L1108)
**Affected subclause:** [[dcl.init.list]](dcl.init.list)
**Change:** Boolean conversion from a pointer or pointer-to-member type
is now a narrowing conversion[.](#4.sentence-1)
**Rationale:** Catches bugs[.](#4.sentence-2)
**Effect on original feature:** Valid C++ 2017 code may fail to compile
in this revision of C++[.](#4.sentence-3)
[*Example [4](#example-4)*: bool y[] = { "bc" }; // ill-formed; previously well-formed — *end example*]

149
cppdraft/diff/cpp17/depr.md Normal file
View File

@@ -0,0 +1,149 @@
[diff.cpp17.depr]
# Annex C (informative) Compatibility [[diff]](./#diff)
## C.3 C++ and ISO C++ 2017 [[diff.cpp17]](diff.cpp17#depr)
### C.3.15 [[depr]](depr "Annex D(normative)Compatibility features"): compatibility features [diff.cpp17.depr]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L1503)
**Change:** Remove uncaught_exception[.](#1.sentence-1)
**Rationale:** The function did not have a clear specification when multiple exceptions were
active, and has been superseded by uncaught_exceptions[.](#1.sentence-2)
**Effect on original feature:** A valid C++ 2017 program that calls std::uncaught_exception may fail
to compile[.](#1.sentence-3)
It can be revised to use std::uncaught_exceptions instead,
for clear and portable semantics[.](#1.sentence-4)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L1514)
**Change:** Remove support for adaptable function API[.](#2.sentence-1)
**Rationale:** The deprecated support relied on a limited convention that could not be
extended to support the general case or new language features[.](#2.sentence-2)
It has been
superseded by direct language support with decltype, and by thestd::bind and std::not_fn function templates[.](#2.sentence-3)
**Effect on original feature:** A valid C++ 2017 program that relies on the presence of result_type,argument_type, first_argument_type, orsecond_argument_type in a standard library class may fail to compile[.](#2.sentence-4)
A
valid C++ 2017 program that calls not1 or not2, or uses the
class templates unary_negate or binary_negate, may fail to
compile[.](#2.sentence-5)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L1530)
**Change:** Remove redundant members from std::allocator[.](#3.sentence-1)
**Rationale:** std::allocator was overspecified, encouraging direct usage in user containers
rather than relying on std::allocator_traits, leading to poor containers[.](#3.sentence-2)
**Effect on original feature:** A valid C++ 2017 program that directly makes use of the pointer,const_pointer, reference, const_reference,rebind, address, construct, destroy, ormax_size members of std::allocator, or that directly callsallocate with an additional hint argument, may fail to compile[.](#3.sentence-3)
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L1543)
**Change:** Remove raw_storage_iterator[.](#4.sentence-1)
**Rationale:** The iterator encouraged use of potentially-throwing algorithms, but did
not return the number of elements successfully constructed,
as would be necessary to destroy them[.](#4.sentence-2)
**Effect on original feature:** A valid C++ 2017 program that uses this iterator class may fail to compile[.](#4.sentence-3)
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L1553)
**Change:** Remove temporary buffers API[.](#5.sentence-1)
**Rationale:** The temporary buffer facility was intended to provide an efficient optimization
for small memory requests, but there is little evidence this was achieved in
practice, while requiring the user to provide their own exception-safe wrappers
to guard use of the facility in many cases[.](#5.sentence-2)
**Effect on original feature:** A valid C++ 2017 program that calls get_temporary_buffer orreturn_temporary_buffer may fail to compile[.](#5.sentence-3)
[6](#6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L1565)
**Change:** Remove shared_ptr::unique[.](#6.sentence-1)
**Rationale:** The result of a call to this member function is not reliable in the presence of
multiple threads and weak pointers[.](#6.sentence-2)
The member function use_count is
similarly unreliable, but has a clearer contract in such cases, and remains
available for well-defined use in single-threaded cases[.](#6.sentence-3)
**Effect on original feature:** A valid C++ 2017 program that calls unique on a shared_ptr object may fail to compile[.](#6.sentence-4)
[7](#7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L1576)
**Affected subclause:** [[depr.meta.types]](depr.meta.types)
**Change:** Remove deprecated type traits[.](#7.sentence-1)
**Rationale:** The traits had unreliable or awkward interfaces[.](#7.sentence-2)
The is_literal_type trait provided no way to detect which subset of constructors and member
functions of a type were declared constexpr[.](#7.sentence-3)
The result_of trait had a surprising syntax that did not directly support function types[.](#7.sentence-4)
It has been superseded by the invoke_result trait[.](#7.sentence-5)
**Effect on original feature:** A valid C++ 2017 program that relies on the is_literal_type orresult_of type traits, on the is_literal_type_v variable template,
or on the result_of_t alias template may fail to compile[.](#7.sentence-6)

View File

@@ -0,0 +1,41 @@
[diff.cpp17.except]
# Annex C (informative) Compatibility [[diff]](./#diff)
## C.3 C++ and ISO C++ 2017 [[diff.cpp17]](diff.cpp17#except)
### C.3.9 [[except]](except "14Exception handling"): exception handling [diff.cpp17.except]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L1308)
**Affected subclause:** [[except.spec]](except.spec)
**Change:** Remove throw() exception specification[.](#1.sentence-1)
**Rationale:** Removal of obsolete feature that has been replaced by noexcept[.](#1.sentence-2)
**Effect on original feature:** A valid C++ 2017 function declaration, member function declaration, function
pointer declaration, or function reference declaration that uses throw() for its exception specification will be rejected as ill-formed in this
revision of C++[.](#1.sentence-3)
It should simply be replaced with noexcept for no
change of meaning since C++ 2017[.](#1.sentence-4)
[*Note [1](#note-1)*:
There is no way to write a function declaration
that is non-throwing in this revision of C++
and is also non-throwing in C++ 2003
except by using the preprocessor to generate
a different token sequence in each case[.](#1.sentence-5)
— *end note*]

View File

@@ -0,0 +1,29 @@
[diff.cpp17.expr]
# Annex C (informative) Compatibility [[diff]](./#diff)
## C.3 C++ and ISO C++ 2017 [[diff.cpp17]](diff.cpp17#expr)
### C.3.4 [[expr]](expr "7Expressions"): expressions [diff.cpp17.expr]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L1010)
**Affected subclause:** [[expr.prim.lambda.capture]](expr.prim.lambda.capture)
**Change:** Implicit lambda capture may capture additional entities[.](#1.sentence-1)
**Rationale:** Rule simplification, necessary to resolve interactions with constexpr if[.](#1.sentence-2)
**Effect on original feature:** Lambdas with a [*capture-default*](expr.prim.lambda.capture#nt:capture-default "7.5.6.3Captures[expr.prim.lambda.capture]") may capture local entities
that were not captured in C++ 2017
if those entities are only referenced in contexts
that do not result in an odr-use[.](#1.sentence-3)

View File

@@ -0,0 +1,16 @@
[diff.cpp17.general]
# Annex C (informative) Compatibility [[diff]](./#diff)
## C.3 C++ and ISO C++ 2017 [[diff.cpp17]](diff.cpp17#general)
### C.3.1 General [diff.cpp17.general]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L834)
Subclause [[diff.cpp17]](diff.cpp17 "C.3C++ and ISO C++ 2017") lists the differences between C++ and
ISO C++ 2017,
in addition to those listed above,
by the chapters of this document[.](#1.sentence-1)

View File

@@ -0,0 +1,97 @@
[diff.cpp17.input.output]
# Annex C (informative) Compatibility [[diff]](./#diff)
## C.3 C++ and ISO C++ 2017 [[diff.cpp17]](diff.cpp17#input.output)
### C.3.14 [[input.output]](input.output "31Input/output library"): input/output library [diff.cpp17.input.output]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L1427)
**Affected subclause:** [[istream.extractors]](istream.extractors)
**Change:** Character array extraction only takes array types[.](#1.sentence-1)
**Rationale:** Increase safety via preventing buffer overflow at compile time[.](#1.sentence-2)
**Effect on original feature:** Valid C++ 2017 code may fail to compile in this revision of C++[.](#1.sentence-3)
[*Example [1](#example-1)*: auto p = new char[100];char q[100];
std::cin >> std::setw(20) >> p; // ill-formed; previously well-formed std::cin >> std::setw(20) >> q; // OK — *end example*]
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L1443)
**Affected subclause:** [[ostream.inserters.character]](ostream.inserters.character)
**Change:** Overload resolution for ostream inserters used with UTF-8 literals[.](#2.sentence-1)
**Rationale:** Required for new features[.](#2.sentence-2)
**Effect on original feature:** Valid C++ 2017 code that passes UTF-8 literals tobasic_ostream<char, ...>::operator<< orbasic_ostream<wchar_t, ...>::operator<< is now ill-formed[.](#2.sentence-3)
[*Example [2](#example-2)*: std::cout << u8"text"; // previously called operator<<(const char*) and printed a string;// now ill-formed std::cout << u8'X'; // previously called operator<<(char) and printed a character;// now ill-formed — *end example*]
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L1462)
**Affected subclause:** [[ostream.inserters.character]](ostream.inserters.character)
**Change:** Overload resolution for ostream inserters
used with wchar_t, char16_t, or char32_t types[.](#3.sentence-1)
**Rationale:** Removal of surprising behavior[.](#3.sentence-2)
**Effect on original feature:** Valid C++ 2017 code that passeswchar_t, char16_t, or char32_t characters or strings
to basic_ostream<char, ...>::operator<< or
that passes char16_t or char32_t characters or strings
to basic_ostream<wchar_t, ...>::operator<< is now ill-formed[.](#3.sentence-3)
[*Example [3](#example-3)*: std::cout << u"text"; // previously formatted the string as a pointer value;// now ill-formed std::cout << u'X'; // previously formatted the character as an integer value;// now ill-formed — *end example*]
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L1483)
**Affected subclause:** [[fs.class.path]](fs.class.path)
**Change:** Return type of filesystem path format observer member functions[.](#4.sentence-1)
**Rationale:** Required for new features[.](#4.sentence-2)
**Effect on original feature:** Valid C++ 2017 code that depends on the u8string() andgeneric_u8string() member functions of std::filesystem::path returning std::string is not valid in this revision of C++[.](#4.sentence-3)
[*Example [4](#example-4)*: std::filesystem::path p;
std::string s1 = p.u8string(); // ill-formed; previously well-formed std::string s2 = p.generic_u8string(); // ill-formed; previously well-formed — *end example*]

View File

@@ -0,0 +1,29 @@
[diff.cpp17.iterators]
# Annex C (informative) Compatibility [[diff]](./#diff)
## C.3 C++ and ISO C++ 2017 [[diff.cpp17]](diff.cpp17#iterators)
### C.3.12 [[iterators]](iterators "24Iterators library"): iterators library [diff.cpp17.iterators]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L1400)
**Affected subclause:** [[iterator.traits]](iterator.traits)
**Change:** The specialization of iterator_traits for void* and
for function pointer types no longer contains any nested typedefs[.](#1.sentence-1)
**Rationale:** Corrects an issue misidentifying pointer types that are not incrementable
as iterator types[.](#1.sentence-2)
**Effect on original feature:** A valid C++ 2017 program that relies on the presence of the typedefs
may fail to compile, or have different behavior[.](#1.sentence-3)

153
cppdraft/diff/cpp17/lex.md Normal file
View File

@@ -0,0 +1,153 @@
[diff.cpp17.lex]
# Annex C (informative) Compatibility [[diff]](./#diff)
## C.3 C++ and ISO C++ 2017 [[diff.cpp17]](diff.cpp17#lex)
### C.3.2 [[lex]](lex "5Lexical conventions"): lexical conventions [diff.cpp17.lex]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L843)
**Affected subclauses:** [[lex.pptoken]](lex.pptoken), [[module.unit]](module.unit), [[module.import]](module.import), [[cpp.pre]](cpp.pre), [[cpp.module]](cpp.module), and [[cpp.import]](cpp.import)
**Change:** New identifiers with special meaning[.](#1.sentence-1)
**Rationale:** Required for new features[.](#1.sentence-2)
**Effect on original feature:** Logical lines beginning withmodule or import may
be interpreted differently
in this revision of C++[.](#1.sentence-3)
[*Example [1](#example-1)*: class module {};module m1; // was variable declaration; now [*module-declaration*](module.unit#nt:module-declaration "10.1Module units and purviews[module.unit]")module *m2; // variable declarationclass import {};import j1; // was variable declaration; now [*module-import-declaration*](module.import#nt:module-import-declaration "10.3Import declaration[module.import]")::import j2; // variable declaration — *end example*]
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L865)
**Affected subclause:** [[lex.header]](lex.header)
**Change:** [*header-name*](lex.header#nt:header-name "5.6Header names[lex.header]") tokens are formed in more contexts[.](#2.sentence-1)
**Rationale:** Required for new features[.](#2.sentence-2)
**Effect on original feature:** When the identifier import is followed by a < character,
a [*header-name*](lex.header#nt:header-name "5.6Header names[lex.header]") token may be formed[.](#2.sentence-3)
[*Example [2](#example-2)*: template<typename> class import {};import<int> f(); // ill-formed; previously well-formed::import<int> g(); // OK — *end example*]
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L882)
**Affected subclause:** [[lex.key]](lex.key)
**Change:** New keywords[.](#3.sentence-1)
**Rationale:** Required for new features[.](#3.sentence-2)
- [(3.1)](#3.1)
The char8_t keyword is added to differentiate
the types of ordinary and UTF-8 literals ([[lex.string]](lex.string "5.13.5String literals"))[.](#3.1.sentence-1)
- [(3.2)](#3.2)
The concept keyword is
added to enable the definition of concepts ([[temp.concept]](temp.concept "13.7.9Concept definitions"))[.](#3.2.sentence-1)
- [(3.3)](#3.3)
The consteval keyword is added to
declare immediate functions ([[dcl.constexpr]](dcl.constexpr "9.2.6The constexpr and consteval specifiers"))[.](#3.3.sentence-1)
- [(3.4)](#3.4)
The constinit keyword is added to
prevent unintended dynamic initialization ([[dcl.constinit]](dcl.constinit "9.2.7The constinit specifier"))[.](#3.4.sentence-1)
- [(3.5)](#3.5)
The co_await, co_yield, and co_return keywords are added
to enable the definition of coroutines ([[dcl.fct.def.coroutine]](dcl.fct.def.coroutine "9.6.4Coroutine definitions"))[.](#3.5.sentence-1)
- [(3.6)](#3.6)
The requires keyword is added
to introduce constraints through a [*requires-clause*](temp.pre#nt:requires-clause "13.1Preamble[temp.pre]") ([[temp.pre]](temp.pre "13.1Preamble"))
or a [*requires-expression*](expr.prim.req.general#nt:requires-expression "7.5.8.1General[expr.prim.req.general]") ([[expr.prim.req]](expr.prim.req "7.5.8Requires expressions"))[.](#3.6.sentence-1)
**Effect on original feature:** Valid C++ 2017 code usingchar8_t,concept,consteval,constinit,co_await, co_yield, co_return,
or requires as an identifier is not valid in this revision of C++[.](#3.sentence-3)
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L919)
**Affected subclause:** [[lex.operators]](lex.operators)
**Change:** New operator <=>[.](#4.sentence-1)
**Rationale:** Necessary for new functionality[.](#4.sentence-2)
**Effect on original feature:** Valid C++ 2017 code that contains a <= token
immediately followed by a > token
may be ill-formed or have different semantics in this revision of C++[.](#4.sentence-3)
[*Example [3](#example-3)*: namespace N {struct X {}; bool operator<=(X, X); template<bool(X, X)> struct Y {};
Y<operator<=> y; // ill-formed; previously well-formed} — *end example*]
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L939)
**Affected subclause:** [[lex.literal]](lex.literal)
**Change:** Type of UTF-8 string and character literals[.](#5.sentence-1)
**Rationale:** Required for new features[.](#5.sentence-2)
The changed types enable function overloading, template specialization, and
type deduction to distinguish ordinary and UTF-8 string and character literals[.](#5.sentence-3)
**Effect on original feature:** Valid C++ 2017 code that depends on
UTF-8 string literals having type “array of const char” and
UTF-8 character literals having type “char”
is not valid in this revision of C++[.](#5.sentence-4)
[*Example [4](#example-4)*: const auto *u8s = u8"text"; // u8s previously deduced as const char*; now deduced as const char8_t*const char *ps = u8s; // ill-formed; previously well-formedauto u8c = u8'c'; // u8c previously deduced as char; now deduced as char8_tchar *pc = &u8c; // ill-formed; previously well-formed std::string s = u8"text"; // ill-formed; previously well-formedvoid f(const char *s);
f(u8"text"); // ill-formed; previously well-formedtemplate<typename> struct ct;template<> struct ct<char> {using type = char;};
ct<decltype(u8'c')>::type x; // ill-formed; previously well-formed. — *end example*]

View File

@@ -0,0 +1,66 @@
[diff.cpp17.library]
# Annex C (informative) Compatibility [[diff]](./#diff)
## C.3 C++ and ISO C++ 2017 [[diff.cpp17]](diff.cpp17#library)
### C.3.10 [[library]](library "16Library introduction"): library introduction [diff.cpp17.library]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L1329)
**Affected subclause:** [[headers]](headers)
**Change:** New headers[.](#1.sentence-1)
**Rationale:** New functionality[.](#1.sentence-2)
**Effect on original feature:** The following C++ headers are new:[<barrier>](barrier.syn#header:%3cbarrier%3e "32.9.3.2Header <barrier> synopsis[barrier.syn]"),[<bit>](bit.general#header:%3cbit%3e "22.11.1General[bit.general]"),[<charconv>](charconv.syn#header:%3ccharconv%3e "28.2.1Header <charconv> synopsis[charconv.syn]"),[<compare>](compare.syn#header:%3ccompare%3e "17.12.1Header <compare> synopsis[compare.syn]"),[<concepts>](concepts.syn#header:%3cconcepts%3e "18.3Header <concepts> synopsis[concepts.syn]"),[<coroutine>](coroutine.syn#header:%3ccoroutine%3e "17.13.2Header <coroutine> synopsis[coroutine.syn]"),[<format>](format.formatter.spec#header:%3cformat%3e "28.5.6.4Formatter specializations[format.formatter.spec]"),[<latch>](latch.syn#header:%3clatch%3e "32.9.2.2Header <latch> synopsis[latch.syn]"),[<numbers>](numbers.syn#header:%3cnumbers%3e "29.8.1Header <numbers> synopsis[numbers.syn]"),[<ranges>](ranges.syn#header:%3cranges%3e "25.2Header <ranges> synopsis[ranges.syn]"),[<semaphore>](semaphore.syn#header:%3csemaphore%3e "32.8.2Header <semaphore> synopsis[semaphore.syn]"),[<source_location>](source.location.syn#header:%3csource_location%3e "17.8.1Header <source_­location> synopsis[source.location.syn]"),[<span>](span.syn#header:%3cspan%3e "23.7.2.1Header <span> synopsis[span.syn]"),[<stop_token>](thread.stoptoken.syn#header:%3cstop_token%3e "32.3.2Header <stop_­token> synopsis[thread.stoptoken.syn]"),[<syncstream>](syncstream.syn#header:%3csyncstream%3e "31.11.1Header <syncstream> synopsis[syncstream.syn]"), and[<version>](version.syn#header:%3cversion%3e "17.3.2Header <version> synopsis[version.syn]")[.](#1.sentence-3)
Valid C++ 2017 code that #includes headers with these names may be
invalid in this revision of C++[.](#1.sentence-4)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L1355)
**Affected subclause:** [[headers]](headers)
**Change:** Remove vacuous C++ header files[.](#2.sentence-1)
**Rationale:** The empty headers implied a false requirement to achieve C compatibility with the C++ headers[.](#2.sentence-2)
**Effect on original feature:** A valid C++ 2017 program that #includes any of the following headers may fail to compile:<ccomplex>,<ciso646>,<cstdalign>,<cstdbool>, and<ctgmath>[.](#2.sentence-3)
To retain the same behavior:
- [(2.1)](#2.1)
a #include of <ccomplex> can be replaced by
a #include of [<complex>](complex.syn#header:%3ccomplex%3e "29.4.2Header <complex> synopsis[complex.syn]"),
- [(2.2)](#2.2)
a #include of <ctgmath> can be replaced by
a #include of [<cmath>](cmath.syn#header:%3ccmath%3e "29.7.1Header <cmath> synopsis[cmath.syn]") and
a #include of [<complex>](complex.syn#header:%3ccomplex%3e "29.4.2Header <complex> synopsis[complex.syn]"),
and
- [(2.3)](#2.3)
a #include of<ciso646>,<cstdalign>, or<cstdbool> can simply be removed[.](#2.sentence-4)

View File

@@ -0,0 +1,62 @@
[diff.cpp17.over]
# Annex C (informative) Compatibility [[diff]](./#diff)
## C.3 C++ and ISO C++ 2017 [[diff.cpp17]](diff.cpp17#over)
### C.3.7 [[over]](over "12Overloading"): overloading [diff.cpp17.over]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L1216)
**Affected subclause:** [[over.match.oper]](over.match.oper)
**Change:** Equality and inequality expressions can now find
reversed and rewritten candidates[.](#1.sentence-1)
**Rationale:** Improve consistency of equality with three-way comparison
and make it easier to write the full complement of equality operations[.](#1.sentence-2)
**Effect on original feature:** For certain pairs of types where one is convertible to the other,
equality or inequality expressions between an object of one type
and an object of the other type invoke a different operator[.](#1.sentence-3)
Also, for certain types, equality or inequality expressions
between two objects of that type become ambiguous[.](#1.sentence-4)
[*Example [1](#example-1)*: struct A {operator int() const;};
bool operator==(A, int); // #1// #2 is built-in candidate: bool operator==(int, int);// #3 is built-in candidate: bool operator!=(int, int);int check(A x, A y) {return (x == y) + // ill-formed; previously well-formed(10 == x) + // calls #1, previously selected #2(10 != x); // calls #1, previously selected #3} — *end example*]
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L1247)
**Affected subclause:** [[over.match.oper]](over.match.oper)
**Change:** Overload resolution may change for equality operators ([[expr.eq]](expr.eq "7.6.10Equality operators"))[.](#2.sentence-1)
**Rationale:** Support calling operator== with reversed order of arguments[.](#2.sentence-2)
**Effect on original feature:** Valid C++ 2017 code that uses equality operators with conversion functions
may be ill-formed or have different semantics in this revision of C++[.](#2.sentence-3)
[*Example [2](#example-2)*: struct A {operator int() const { return 10; }};
bool operator==(A, int); // #1// #2 is built-in candidate: bool operator==(int, int);bool b = 10 == A(); // calls #1 with reversed order of arguments; previously selected #2struct B {bool operator==(const B&); // member function with no cv-qualifier};
B b1;bool eq = (b1 == b1); // ambiguous; previously well-formed — *end example*]

View File

@@ -0,0 +1,37 @@
[diff.cpp17.temp]
# Annex C (informative) Compatibility [[diff]](./#diff)
## C.3 C++ and ISO C++ 2017 [[diff.cpp17]](diff.cpp17#temp)
### C.3.8 [[temp]](temp "13Templates"): templates [diff.cpp17.temp]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L1275)
**Affected subclause:** [[temp.names]](temp.names)
**Change:** An [*unqualified-id*](expr.prim.id.unqual#nt:unqualified-id "7.5.5.2Unqualified names[expr.prim.id.unqual]") that is followed by a < and for which name lookup
finds nothing or finds a function
will be treated as a [*template-name*](temp.names#nt:template-name "13.3Names of template specializations[temp.names]") in order to potentially cause argument-dependent lookup to be performed[.](#1.sentence-1)
**Rationale:** It was problematic to call a function template
with an explicit template argument list
via argument-dependent lookup
because of the need to have a template with the same name
visible via normal lookup[.](#1.sentence-2)
**Effect on original feature:** Previously valid code that uses a function name
as the left operand of a < operator
would become ill-formed[.](#1.sentence-3)
[*Example [1](#example-1)*: struct A {};bool operator<(void (*fp)(), A);void f() {}int main() { A a;
f < a; // ill-formed; previously well-formed(f) < a; // still well-formed} — *end example*]

452
cppdraft/diff/cpp20.md Normal file
View File

@@ -0,0 +1,452 @@
[diff.cpp20]
# Annex C (informative) Compatibility [[diff]](./#diff)
## C.2 C++ and ISO C++ 2020 [diff.cpp20]
### [C.2.1](#general) General [[diff.cpp20.general]](diff.cpp20.general)
[1](#general-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L461)
Subclause [diff.cpp20] lists the differences between C++ and
ISO C++ 2020,
in addition to those listed above,
by the chapters of this document[.](#general-1.sentence-1)
### [C.2.2](#lex) [[lex]](lex "5Lexical conventions"): lexical conventions [[diff.cpp20.lex]](diff.cpp20.lex)
[1](#lex-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L470)
**Affected subclause:** [[lex.name]](lex.name)
**Change:** Previously valid identifiers containing characters
not present in UAX #44 properties XID_Start or XID_Continue, or
not in Normalization Form C, are now rejected[.](#lex-1.sentence-1)
**Rationale:** Prevent confusing characters in identifiers[.](#lex-1.sentence-2)
Requiring normalization of names ensures consistent linker behavior[.](#lex-1.sentence-3)
**Effect on original feature:** Some identifiers are no longer well-formed[.](#lex-1.sentence-4)
[2](#lex-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L483)
**Affected subclause:** [[lex.string]](lex.string)
**Change:** Concatenated [*string-literal*](lex.string#nt:string-literal "5.13.5String literals[lex.string]")*s* can no longer have
conflicting [*encoding-prefix*](lex.ccon#nt:encoding-prefix "5.13.3Character literals[lex.ccon]")es[.](#lex-2.sentence-1)
**Rationale:** Removal of unimplemented conditionally-supported feature[.](#lex-2.sentence-2)
**Effect on original feature:** Concatenation of [*string-literal*](lex.string#nt:string-literal "5.13.5String literals[lex.string]")*s* with different [*encoding-prefix*](lex.ccon#nt:encoding-prefix "5.13.3Character literals[lex.ccon]")es
is now ill-formed[.](#lex-2.sentence-3)
[*Example [1](#lex-example-1)*: auto c = L"a" U"b"; // was conditionally-supported; now ill-formed — *end example*]
### [C.2.3](#expr) [[expr]](expr "7Expressions"): expressions [[diff.cpp20.expr]](diff.cpp20.expr)
[1](#expr-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L501)
**Affected subclause:** [[expr.prim.id.unqual]](expr.prim.id.unqual)
**Change:** Change move-eligible [*id-expression*](expr.prim.id.general#nt:id-expression "7.5.5.1General[expr.prim.id.general]")*s* from lvalues to xvalues[.](#expr-1.sentence-1)
**Rationale:** Simplify the rules for implicit move[.](#expr-1.sentence-2)
**Effect on original feature:** Valid C++ 2020 code that relies on a returned [*id-expression*](expr.prim.id.general#nt:id-expression "7.5.5.1General[expr.prim.id.general]")'s
being an lvalue may change behavior or fail to compile[.](#expr-1.sentence-3)
[*Example [1](#expr-example-1)*: decltype(auto) f(int&& x) { return (x); } // returns int&&; previously returned int&int& g(int&& x) { return x; } // ill-formed; previously well-formed — *end example*]
[2](#expr-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L516)
**Affected subclause:** [[expr.sub]](expr.sub)
**Change:** Change the meaning of comma in subscript expressions[.](#expr-2.sentence-1)
**Rationale:** Enable repurposing a deprecated syntax to support multidimensional indexing[.](#expr-2.sentence-2)
**Effect on original feature:** Valid C++ 2020 code that uses a comma expression within a
subscript expression may fail to compile[.](#expr-2.sentence-3)
[*Example [2](#expr-example-2)*: arr[1, 2] // was equivalent to arr[(1, 2)],// now equivalent to arr.operator[](1, 2) or ill-formed — *end example*]
### [C.2.4](#stmt) [[stmt]](stmt "8Statements"): statements [[diff.cpp20.stmt]](diff.cpp20.stmt)
[1](#stmt-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L533)
**Affected subclause:** [[stmt.ranged]](stmt.ranged)
**Change:** The lifetime of temporary objects in the [*for-range-initializer*](stmt.pre#nt:for-range-initializer "8.1Preamble[stmt.pre]") is extended until the end of the loop ([[class.temporary]](class.temporary "6.8.7Temporary objects"))[.](#stmt-1.sentence-1)
**Rationale:** Improve usability of the range-based for statement[.](#stmt-1.sentence-2)
**Effect on original feature:** Destructors of some temporary objects are invoked later[.](#stmt-1.sentence-3)
[*Example [1](#stmt-example-1)*: void f() { std::vector<int> v = { 42, 17, 13 };
std::mutex m; for (int x :static_cast<void>(std::lock_guard<std::mutex>(m)), v) { // lock released in C++ 2020 std::lock_guard<std::mutex> guard(m); // OK in C++ 2020, now deadlocks}} — *end example*]
### [C.2.5](#dcl) [[dcl]](dcl "9Declarations"): declarations [[diff.cpp20.dcl]](diff.cpp20.dcl)
[1](#dcl-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L557)
**Affected subclause:** [[dcl.init.string]](dcl.init.string)
**Change:** UTF-8 string literals may initialize arrays of char orunsigned char[.](#dcl-1.sentence-1)
**Rationale:** Compatibility with previously written code that conformed to previous versions of this document[.](#dcl-1.sentence-2)
**Effect on original feature:** Arrays of char or unsigned char may now be initialized with a UTF-8 string literal[.](#dcl-1.sentence-3)
This can affect initialization that includes arrays
that are directly initialized within class types, typically aggregates[.](#dcl-1.sentence-4)
[*Example [1](#dcl-example-1)*: struct A {char8_t s[10];};struct B {char s[10];};
void f(A);void f(B);
int main() { f({u8""}); // ambiguous} — *end example*]
### [C.2.6](#temp) [[temp]](temp "13Templates"): templates [[diff.cpp20.temp]](diff.cpp20.temp)
[1](#temp-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L588)
**Affected subclause:** [[temp.deduct.type]](temp.deduct.type)
**Change:** Deducing template arguments from exception specifications[.](#temp-1.sentence-1)
**Rationale:** Facilitate generic handling of throwing and non-throwing functions[.](#temp-1.sentence-2)
**Effect on original feature:** Valid ISO C++ 2020 code may be ill-formed in this revision of C++[.](#temp-1.sentence-3)
[*Example [1](#temp-example-1)*: template<bool> struct A { };template<bool B> void f(void (*)(A<B>) noexcept(B));void g(A<false>) noexcept;void h() { f(g); // ill-formed; previously well-formed} — *end example*]
### [C.2.7](#library) [[library]](library "16Library introduction"): library introduction [[diff.cpp20.library]](diff.cpp20.library)
[1](#library-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L608)
**Affected subclause:** [[headers]](headers)
**Change:** New headers[.](#library-1.sentence-1)
**Rationale:** New functionality[.](#library-1.sentence-2)
**Effect on original feature:** The following C++ headers are new:[<expected>](expected.syn#header:%3cexpected%3e "22.8.2Header <expected> synopsis[expected.syn]"),[<flat_map>](flat.map.syn#header:%3cflat_map%3e "23.6.7Header <flat_­map> synopsis[flat.map.syn]"),[<flat_set>](flat.set.syn#header:%3cflat_set%3e "23.6.10Header <flat_­set> synopsis[flat.set.syn]"),[<generator>](generator.syn#header:%3cgenerator%3e "25.8.2Header <generator> synopsis[generator.syn]"),[<mdspan>](mdspan.syn#header:%3cmdspan%3e "23.7.3.2Header <mdspan> synopsis[mdspan.syn]"),[<print>](print.syn#header:%3cprint%3e "31.7.4Header <print> synopsis[print.syn]"),[<spanstream>](span.streams.overview#header:%3cspanstream%3e "31.9.1Overview[span.streams.overview]"),[<stacktrace>](stacktrace.syn#header:%3cstacktrace%3e "19.6.2Header <stacktrace> synopsis[stacktrace.syn]"),[<stdatomic.h>](stdatomic.h.syn#header:%3cstdatomic.h%3e "32.5.12C compatibility[stdatomic.h.syn]"), and[<stdfloat>](stdfloat.syn#header:%3cstdfloat%3e "17.4.2Header <stdfloat> synopsis[stdfloat.syn]")[.](#library-1.sentence-3)
Valid C++ 2020 code that #includes headers with these names may be
invalid in this revision of C++[.](#library-1.sentence-4)
### [C.2.8](#concepts) [[concepts]](concepts "18Concepts library"): concepts library [[diff.cpp20.concepts]](diff.cpp20.concepts)
[1](#concepts-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L630)
**Affected subclauses:** [[cmp.concept]](cmp.concept), [[concept.equalitycomparable]](concept.equalitycomparable), and [[concept.totallyordered]](concept.totallyordered)
**Change:** Replace common_reference_with in three_way_comparable_with,equality_comparable_with, and totally_ordered_with with an exposition-only concept[.](#concepts-1.sentence-1)
**Rationale:** Allow uncopyable, but movable, types to model these concepts[.](#concepts-1.sentence-2)
**Effect on original feature:** Valid C++ 2020 code relying on subsumption
with common_reference_with may fail to compile in this revision of C++[.](#concepts-1.sentence-3)
[*Example [1](#concepts-example-1)*: template<class T, class U>requires [equality_comparable_with](concept.equalitycomparable#concept:equality_comparable_with "18.5.4Concept equality_­comparable[concept.equalitycomparable]")<T, U>bool attempted_equals(const T&, const U& u); // previously selected overloadtemplate<class T, class U>requires [common_reference_with](concept.commonref#concept:common_reference_with "18.4.5Concept common_­reference_­with[concept.commonref]")<const remove_reference_t<T>&, const remove_reference_t<U>&>bool attempted_equals(const T& t, const U& u); // ambiguous overload; previously// rejected by partial orderingbool test(shared_ptr<int> p) {return attempted_equals(p, nullptr); // ill-formed; previously well-formed} — *end example*]
### [C.2.9](#memory) [[mem]](mem "20Memory management library"): memory management library [[diff.cpp20.memory]](diff.cpp20.memory)
[1](#memory-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L659)
**Affected subclause:** [[allocator.traits.general]](allocator.traits.general)
**Change:** Forbid partial and explicit program-defined specializations
of allocator_traits[.](#memory-1.sentence-1)
**Rationale:** Allow addition of allocate_at_least to allocator_traits,
and potentially other members in the future[.](#memory-1.sentence-2)
**Effect on original feature:** Valid C++ 2020 code
that partially or explicitly specializes allocator_traits is ill-formed with no diagnostic required in this revision of C++[.](#memory-1.sentence-3)
### [C.2.10](#utilities) [[utilities]](utilities "22General utilities library"): general utilities library [[diff.cpp20.utilities]](diff.cpp20.utilities)
[1](#utilities-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L673)
**Affected subclause:** [[format]](format)
**Change:** Signature changes: format, format_to, vformat_to,format_to_n, formatted_size[.](#utilities-1.sentence-1)
Removal of format_args_t[.](#utilities-1.sentence-2)
**Rationale:** Improve safety via compile-time format string checks,
avoid unnecessary template instantiations[.](#utilities-1.sentence-3)
**Effect on original feature:** Valid C++ 2020 code that
contained errors in format strings or
relied on previous format string signatures orformat_args_t may become ill-formed[.](#utilities-1.sentence-4)
[*Example [1](#utilities-example-1)*: auto s = std::format("{:d}", "I am not a number"); // ill-formed,// previously threw format_error — *end example*]
[2](#utilities-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L693)
**Affected subclause:** [[format]](format)
**Change:** Signature changes: format, format_to, format_to_n,formatted_size[.](#utilities-2.sentence-1)
**Rationale:** Enable formatting of views
that do not support iteration when const-qualified and
that are not copyable[.](#utilities-2.sentence-2)
**Effect on original feature:** Valid C++ 2020 code that passes bit-fields to formatting functions
may become ill-formed[.](#utilities-2.sentence-3)
[*Example [2](#utilities-example-2)*: struct tiny {int bit: 1;};
auto t = tiny();
std::format("{}", t.bit); // ill-formed, previously returned "0" — *end example*]
[3](#utilities-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L715)
**Affected subclause:** [[format.string.std]](format.string.std)
**Change:** Restrict types of formatting arguments
used as *width* or *precision* in
a *std-format-spec*[.](#utilities-3.sentence-1)
**Rationale:** Disallow types that do not have useful or portable semantics as
a formatting width or precision[.](#utilities-3.sentence-2)
**Effect on original feature:** Valid C++ 2020 code that passes a boolean or character type as*arg-id* becomes invalid[.](#utilities-3.sentence-3)
[*Example [3](#utilities-example-3)*: std::format("{:*^{}}", "", true); // ill-formed, previously returned "*" std::format("{:*^{}}", "", '1'); // ill-formed, previously returned an// implementation-defined number of '*' characters — *end example*]
[4](#utilities-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L734)
**Affected subclause:** [[format.formatter.spec]](format.formatter.spec)
**Change:** Removed the formatter specialization:template<size_t N> struct formatter<const charT[N], charT>;
**Rationale:** The specialization is inconsistent with the design of formatter,
which is intended to be instantiated only with cv-unqualified object types[.](#utilities-4.sentence-2)
**Effect on original feature:** Valid C++ 2020 code that instantiated the removed specialization
can become ill-formed[.](#utilities-4.sentence-3)
### [C.2.11](#strings) [[strings]](strings "27Strings library"): strings library [[diff.cpp20.strings]](diff.cpp20.strings)
[1](#strings-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L749)
**Affected subclause:** [[string.classes]](string.classes)
**Change:** Additional rvalue overload for the substr member function and
the corresponding constructor[.](#strings-1.sentence-1)
**Rationale:** Improve efficiency of operations on rvalues[.](#strings-1.sentence-2)
**Effect on original feature:** Valid C++ 2020 code that created a substring
by calling substr (or the corresponding constructor)
on an xvalue expression with type S that is a specialization of basic_string may change meaning in this revision of C++[.](#strings-1.sentence-3)
[*Example [1](#strings-example-1)*: std::string s1 = "some long string that forces allocation", s2 = s1;
std::move(s1).substr(10, 5);
assert(s1 == s2); // unspecified, previously guaranteed to be true std::string s3(std::move(s2), 10, 5);
assert(s1 == s2); // unspecified, previously guaranteed to be true — *end example*]
### [C.2.12](#containers) [[containers]](containers "23Containers library"): containers library [[diff.cpp20.containers]](diff.cpp20.containers)
[1](#containers-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L773)
**Affected subclauses:** [[associative.reqmts]](associative.reqmts) and [[unord.req]](unord.req)
**Change:** Heterogeneous extract and erase overloads
for associative containers[.](#containers-1.sentence-1)
**Rationale:** Improve efficiency of erasing elements from associative containers[.](#containers-1.sentence-2)
**Effect on original feature:** Valid C++ 2020 code may fail to compile in this revision of C++[.](#containers-1.sentence-3)
[*Example [1](#containers-example-1)*: struct B {auto operator<=>(const B&) const = default;};
struct D : private B {void f(std::set<B, std::less<>>& s) { s.erase(*this); // ill-formed; previously well-formed}}; — *end example*]
### [C.2.13](#thread) [[thread]](thread "32Concurrency support library"): concurrency support library [[diff.cpp20.thread]](diff.cpp20.thread)
[1](#thread-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L797)
**Affected subclause:** [[thread.barrier]](thread.barrier)
**Change:** In this revision of C++,
it is implementation-defined whether a barrier's phase completion step runs
if no thread calls wait[.](#thread-1.sentence-1)
Previously the phase completion step was guaranteed to run on the last thread that calls arrive or arrive_and_drop during the phase[.](#thread-1.sentence-2)
In this revision of C++,
it can run on any of the threads that arrived or waited at the barrier
during the phase[.](#thread-1.sentence-3)
**Rationale:** Correct contradictory wording and
improve implementation flexibility for performance[.](#thread-1.sentence-4)
**Effect on original feature:** Valid C++ 2020 code using a barrier might have
different semantics in this revision of C++
if it depends on a completion function's side effects occurring exactly once,
on a specific thread running the phase completion step, or
on a completion function's side effects occurring
without wait having been called[.](#thread-1.sentence-5)
[*Example [1](#thread-example-1)*: auto b0 = std::barrier(1);
b0.arrive();
b0.arrive(); // implementation-defined; previously well-definedint data = 0;auto b1 = std::barrier(1, [&] { data++; });
b1.arrive();
assert(data == 1); // implementation-defined; previously well-defined b1.arrive(); // implementation-defined; previously well-defined — *end example*]

View File

@@ -0,0 +1,29 @@
[diff.cpp20.concepts]
# Annex C (informative) Compatibility [[diff]](./#diff)
## C.2 C++ and ISO C++ 2020 [[diff.cpp20]](diff.cpp20#concepts)
### C.2.8 [[concepts]](concepts "18Concepts library"): concepts library [diff.cpp20.concepts]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L630)
**Affected subclauses:** [[cmp.concept]](cmp.concept), [[concept.equalitycomparable]](concept.equalitycomparable), and [[concept.totallyordered]](concept.totallyordered)
**Change:** Replace common_reference_with in three_way_comparable_with,equality_comparable_with, and totally_ordered_with with an exposition-only concept[.](#1.sentence-1)
**Rationale:** Allow uncopyable, but movable, types to model these concepts[.](#1.sentence-2)
**Effect on original feature:** Valid C++ 2020 code relying on subsumption
with common_reference_with may fail to compile in this revision of C++[.](#1.sentence-3)
[*Example [1](#example-1)*: template<class T, class U>requires [equality_comparable_with](concept.equalitycomparable#concept:equality_comparable_with "18.5.4Concept equality_­comparable[concept.equalitycomparable]")<T, U>bool attempted_equals(const T&, const U& u); // previously selected overloadtemplate<class T, class U>requires [common_reference_with](concept.commonref#concept:common_reference_with "18.4.5Concept common_­reference_­with[concept.commonref]")<const remove_reference_t<T>&, const remove_reference_t<U>&>bool attempted_equals(const T& t, const U& u); // ambiguous overload; previously// rejected by partial orderingbool test(shared_ptr<int> p) {return attempted_equals(p, nullptr); // ill-formed; previously well-formed} — *end example*]

View File

@@ -0,0 +1,31 @@
[diff.cpp20.containers]
# Annex C (informative) Compatibility [[diff]](./#diff)
## C.2 C++ and ISO C++ 2020 [[diff.cpp20]](diff.cpp20#containers)
### C.2.12 [[containers]](containers "23Containers library"): containers library [diff.cpp20.containers]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L773)
**Affected subclauses:** [[associative.reqmts]](associative.reqmts) and [[unord.req]](unord.req)
**Change:** Heterogeneous extract and erase overloads
for associative containers[.](#1.sentence-1)
**Rationale:** Improve efficiency of erasing elements from associative containers[.](#1.sentence-2)
**Effect on original feature:** Valid C++ 2020 code may fail to compile in this revision of C++[.](#1.sentence-3)
[*Example [1](#example-1)*: struct B {auto operator<=>(const B&) const = default;};
struct D : private B {void f(std::set<B, std::less<>>& s) { s.erase(*this); // ill-formed; previously well-formed}}; — *end example*]

View File

@@ -0,0 +1,35 @@
[diff.cpp20.dcl]
# Annex C (informative) Compatibility [[diff]](./#diff)
## C.2 C++ and ISO C++ 2020 [[diff.cpp20]](diff.cpp20#dcl)
### C.2.5 [[dcl]](dcl "9Declarations"): declarations [diff.cpp20.dcl]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L557)
**Affected subclause:** [[dcl.init.string]](dcl.init.string)
**Change:** UTF-8 string literals may initialize arrays of char orunsigned char[.](#1.sentence-1)
**Rationale:** Compatibility with previously written code that conformed to previous versions of this document[.](#1.sentence-2)
**Effect on original feature:** Arrays of char or unsigned char may now be initialized with a UTF-8 string literal[.](#1.sentence-3)
This can affect initialization that includes arrays
that are directly initialized within class types, typically aggregates[.](#1.sentence-4)
[*Example [1](#example-1)*: struct A {char8_t s[10];};struct B {char s[10];};
void f(A);void f(B);
int main() { f({u8""}); // ambiguous} — *end example*]

View File

@@ -0,0 +1,51 @@
[diff.cpp20.expr]
# Annex C (informative) Compatibility [[diff]](./#diff)
## C.2 C++ and ISO C++ 2020 [[diff.cpp20]](diff.cpp20#expr)
### C.2.3 [[expr]](expr "7Expressions"): expressions [diff.cpp20.expr]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L501)
**Affected subclause:** [[expr.prim.id.unqual]](expr.prim.id.unqual)
**Change:** Change move-eligible [*id-expression*](expr.prim.id.general#nt:id-expression "7.5.5.1General[expr.prim.id.general]")*s* from lvalues to xvalues[.](#1.sentence-1)
**Rationale:** Simplify the rules for implicit move[.](#1.sentence-2)
**Effect on original feature:** Valid C++ 2020 code that relies on a returned [*id-expression*](expr.prim.id.general#nt:id-expression "7.5.5.1General[expr.prim.id.general]")'s
being an lvalue may change behavior or fail to compile[.](#1.sentence-3)
[*Example [1](#example-1)*: decltype(auto) f(int&& x) { return (x); } // returns int&&; previously returned int&int& g(int&& x) { return x; } // ill-formed; previously well-formed — *end example*]
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L516)
**Affected subclause:** [[expr.sub]](expr.sub)
**Change:** Change the meaning of comma in subscript expressions[.](#2.sentence-1)
**Rationale:** Enable repurposing a deprecated syntax to support multidimensional indexing[.](#2.sentence-2)
**Effect on original feature:** Valid C++ 2020 code that uses a comma expression within a
subscript expression may fail to compile[.](#2.sentence-3)
[*Example [2](#example-2)*: arr[1, 2] // was equivalent to arr[(1, 2)],// now equivalent to arr.operator[](1, 2) or ill-formed — *end example*]

View File

@@ -0,0 +1,16 @@
[diff.cpp20.general]
# Annex C (informative) Compatibility [[diff]](./#diff)
## C.2 C++ and ISO C++ 2020 [[diff.cpp20]](diff.cpp20#general)
### C.2.1 General [diff.cpp20.general]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L461)
Subclause [[diff.cpp20]](diff.cpp20 "C.2C++ and ISO C++ 2020") lists the differences between C++ and
ISO C++ 2020,
in addition to those listed above,
by the chapters of this document[.](#1.sentence-1)

View File

@@ -0,0 +1,53 @@
[diff.cpp20.lex]
# Annex C (informative) Compatibility [[diff]](./#diff)
## C.2 C++ and ISO C++ 2020 [[diff.cpp20]](diff.cpp20#lex)
### C.2.2 [[lex]](lex "5Lexical conventions"): lexical conventions [diff.cpp20.lex]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L470)
**Affected subclause:** [[lex.name]](lex.name)
**Change:** Previously valid identifiers containing characters
not present in UAX #44 properties XID_Start or XID_Continue, or
not in Normalization Form C, are now rejected[.](#1.sentence-1)
**Rationale:** Prevent confusing characters in identifiers[.](#1.sentence-2)
Requiring normalization of names ensures consistent linker behavior[.](#1.sentence-3)
**Effect on original feature:** Some identifiers are no longer well-formed[.](#1.sentence-4)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L483)
**Affected subclause:** [[lex.string]](lex.string)
**Change:** Concatenated [*string-literal*](lex.string#nt:string-literal "5.13.5String literals[lex.string]")*s* can no longer have
conflicting [*encoding-prefix*](lex.ccon#nt:encoding-prefix "5.13.3Character literals[lex.ccon]")es[.](#2.sentence-1)
**Rationale:** Removal of unimplemented conditionally-supported feature[.](#2.sentence-2)
**Effect on original feature:** Concatenation of [*string-literal*](lex.string#nt:string-literal "5.13.5String literals[lex.string]")*s* with different [*encoding-prefix*](lex.ccon#nt:encoding-prefix "5.13.3Character literals[lex.ccon]")es
is now ill-formed[.](#2.sentence-3)
[*Example [1](#example-1)*: auto c = L"a" U"b"; // was conditionally-supported; now ill-formed — *end example*]

View File

@@ -0,0 +1,29 @@
[diff.cpp20.library]
# Annex C (informative) Compatibility [[diff]](./#diff)
## C.2 C++ and ISO C++ 2020 [[diff.cpp20]](diff.cpp20#library)
### C.2.7 [[library]](library "16Library introduction"): library introduction [diff.cpp20.library]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L608)
**Affected subclause:** [[headers]](headers)
**Change:** New headers[.](#1.sentence-1)
**Rationale:** New functionality[.](#1.sentence-2)
**Effect on original feature:** The following C++ headers are new:[<expected>](expected.syn#header:%3cexpected%3e "22.8.2Header <expected> synopsis[expected.syn]"),[<flat_map>](flat.map.syn#header:%3cflat_map%3e "23.6.7Header <flat_­map> synopsis[flat.map.syn]"),[<flat_set>](flat.set.syn#header:%3cflat_set%3e "23.6.10Header <flat_­set> synopsis[flat.set.syn]"),[<generator>](generator.syn#header:%3cgenerator%3e "25.8.2Header <generator> synopsis[generator.syn]"),[<mdspan>](mdspan.syn#header:%3cmdspan%3e "23.7.3.2Header <mdspan> synopsis[mdspan.syn]"),[<print>](print.syn#header:%3cprint%3e "31.7.4Header <print> synopsis[print.syn]"),[<spanstream>](span.streams.overview#header:%3cspanstream%3e "31.9.1Overview[span.streams.overview]"),[<stacktrace>](stacktrace.syn#header:%3cstacktrace%3e "19.6.2Header <stacktrace> synopsis[stacktrace.syn]"),[<stdatomic.h>](stdatomic.h.syn#header:%3cstdatomic.h%3e "32.5.12C compatibility[stdatomic.h.syn]"), and[<stdfloat>](stdfloat.syn#header:%3cstdfloat%3e "17.4.2Header <stdfloat> synopsis[stdfloat.syn]")[.](#1.sentence-3)
Valid C++ 2020 code that #includes headers with these names may be
invalid in this revision of C++[.](#1.sentence-4)

View File

@@ -0,0 +1,29 @@
[diff.cpp20.memory]
# Annex C (informative) Compatibility [[diff]](./#diff)
## C.2 C++ and ISO C++ 2020 [[diff.cpp20]](diff.cpp20#memory)
### C.2.9 [[mem]](mem "20Memory management library"): memory management library [diff.cpp20.memory]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L659)
**Affected subclause:** [[allocator.traits.general]](allocator.traits.general)
**Change:** Forbid partial and explicit program-defined specializations
of allocator_traits[.](#1.sentence-1)
**Rationale:** Allow addition of allocate_at_least to allocator_traits,
and potentially other members in the future[.](#1.sentence-2)
**Effect on original feature:** Valid C++ 2020 code
that partially or explicitly specializes allocator_traits is ill-formed with no diagnostic required in this revision of C++[.](#1.sentence-3)

View File

@@ -0,0 +1,29 @@
[diff.cpp20.stmt]
# Annex C (informative) Compatibility [[diff]](./#diff)
## C.2 C++ and ISO C++ 2020 [[diff.cpp20]](diff.cpp20#stmt)
### C.2.4 [[stmt]](stmt "8Statements"): statements [diff.cpp20.stmt]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L533)
**Affected subclause:** [[stmt.ranged]](stmt.ranged)
**Change:** The lifetime of temporary objects in the [*for-range-initializer*](stmt.pre#nt:for-range-initializer "8.1Preamble[stmt.pre]") is extended until the end of the loop ([[class.temporary]](class.temporary "6.8.7Temporary objects"))[.](#1.sentence-1)
**Rationale:** Improve usability of the range-based for statement[.](#1.sentence-2)
**Effect on original feature:** Destructors of some temporary objects are invoked later[.](#1.sentence-3)
[*Example [1](#example-1)*: void f() { std::vector<int> v = { 42, 17, 13 };
std::mutex m; for (int x :static_cast<void>(std::lock_guard<std::mutex>(m)), v) { // lock released in C++ 2020 std::lock_guard<std::mutex> guard(m); // OK in C++ 2020, now deadlocks}} — *end example*]

View File

@@ -0,0 +1,34 @@
[diff.cpp20.strings]
# Annex C (informative) Compatibility [[diff]](./#diff)
## C.2 C++ and ISO C++ 2020 [[diff.cpp20]](diff.cpp20#strings)
### C.2.11 [[strings]](strings "27Strings library"): strings library [diff.cpp20.strings]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L749)
**Affected subclause:** [[string.classes]](string.classes)
**Change:** Additional rvalue overload for the substr member function and
the corresponding constructor[.](#1.sentence-1)
**Rationale:** Improve efficiency of operations on rvalues[.](#1.sentence-2)
**Effect on original feature:** Valid C++ 2020 code that created a substring
by calling substr (or the corresponding constructor)
on an xvalue expression with type S that is a specialization of basic_string may change meaning in this revision of C++[.](#1.sentence-3)
[*Example [1](#example-1)*: std::string s1 = "some long string that forces allocation", s2 = s1;
std::move(s1).substr(10, 5);
assert(s1 == s2); // unspecified, previously guaranteed to be true std::string s3(std::move(s2), 10, 5);
assert(s1 == s2); // unspecified, previously guaranteed to be true — *end example*]

View File

@@ -0,0 +1,28 @@
[diff.cpp20.temp]
# Annex C (informative) Compatibility [[diff]](./#diff)
## C.2 C++ and ISO C++ 2020 [[diff.cpp20]](diff.cpp20#temp)
### C.2.6 [[temp]](temp "13Templates"): templates [diff.cpp20.temp]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L588)
**Affected subclause:** [[temp.deduct.type]](temp.deduct.type)
**Change:** Deducing template arguments from exception specifications[.](#1.sentence-1)
**Rationale:** Facilitate generic handling of throwing and non-throwing functions[.](#1.sentence-2)
**Effect on original feature:** Valid ISO C++ 2020 code may be ill-formed in this revision of C++[.](#1.sentence-3)
[*Example [1](#example-1)*: template<bool> struct A { };template<bool B> void f(void (*)(A<B>) noexcept(B));void g(A<false>) noexcept;void h() { f(g); // ill-formed; previously well-formed} — *end example*]

View File

@@ -0,0 +1,46 @@
[diff.cpp20.thread]
# Annex C (informative) Compatibility [[diff]](./#diff)
## C.2 C++ and ISO C++ 2020 [[diff.cpp20]](diff.cpp20#thread)
### C.2.13 [[thread]](thread "32Concurrency support library"): concurrency support library [diff.cpp20.thread]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L797)
**Affected subclause:** [[thread.barrier]](thread.barrier)
**Change:** In this revision of C++,
it is implementation-defined whether a barrier's phase completion step runs
if no thread calls wait[.](#1.sentence-1)
Previously the phase completion step was guaranteed to run on the last thread that calls arrive or arrive_and_drop during the phase[.](#1.sentence-2)
In this revision of C++,
it can run on any of the threads that arrived or waited at the barrier
during the phase[.](#1.sentence-3)
**Rationale:** Correct contradictory wording and
improve implementation flexibility for performance[.](#1.sentence-4)
**Effect on original feature:** Valid C++ 2020 code using a barrier might have
different semantics in this revision of C++
if it depends on a completion function's side effects occurring exactly once,
on a specific thread running the phase completion step, or
on a completion function's side effects occurring
without wait having been called[.](#1.sentence-5)
[*Example [1](#example-1)*: auto b0 = std::barrier(1);
b0.arrive();
b0.arrive(); // implementation-defined; previously well-definedint data = 0;auto b1 = std::barrier(1, [&] { data++; });
b1.arrive();
assert(data == 1); // implementation-defined; previously well-defined b1.arrive(); // implementation-defined; previously well-defined — *end example*]

View File

@@ -0,0 +1,102 @@
[diff.cpp20.utilities]
# Annex C (informative) Compatibility [[diff]](./#diff)
## C.2 C++ and ISO C++ 2020 [[diff.cpp20]](diff.cpp20#utilities)
### C.2.10 [[utilities]](utilities "22General utilities library"): general utilities library [diff.cpp20.utilities]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L673)
**Affected subclause:** [[format]](format)
**Change:** Signature changes: format, format_to, vformat_to,format_to_n, formatted_size[.](#1.sentence-1)
Removal of format_args_t[.](#1.sentence-2)
**Rationale:** Improve safety via compile-time format string checks,
avoid unnecessary template instantiations[.](#1.sentence-3)
**Effect on original feature:** Valid C++ 2020 code that
contained errors in format strings or
relied on previous format string signatures orformat_args_t may become ill-formed[.](#1.sentence-4)
[*Example [1](#example-1)*: auto s = std::format("{:d}", "I am not a number"); // ill-formed,// previously threw format_error — *end example*]
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L693)
**Affected subclause:** [[format]](format)
**Change:** Signature changes: format, format_to, format_to_n,formatted_size[.](#2.sentence-1)
**Rationale:** Enable formatting of views
that do not support iteration when const-qualified and
that are not copyable[.](#2.sentence-2)
**Effect on original feature:** Valid C++ 2020 code that passes bit-fields to formatting functions
may become ill-formed[.](#2.sentence-3)
[*Example [2](#example-2)*: struct tiny {int bit: 1;};
auto t = tiny();
std::format("{}", t.bit); // ill-formed, previously returned "0" — *end example*]
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L715)
**Affected subclause:** [[format.string.std]](format.string.std)
**Change:** Restrict types of formatting arguments
used as *width* or *precision* in
a *std-format-spec*[.](#3.sentence-1)
**Rationale:** Disallow types that do not have useful or portable semantics as
a formatting width or precision[.](#3.sentence-2)
**Effect on original feature:** Valid C++ 2020 code that passes a boolean or character type as*arg-id* becomes invalid[.](#3.sentence-3)
[*Example [3](#example-3)*: std::format("{:*^{}}", "", true); // ill-formed, previously returned "*" std::format("{:*^{}}", "", '1'); // ill-formed, previously returned an// implementation-defined number of '*' characters — *end example*]
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L734)
**Affected subclause:** [[format.formatter.spec]](format.formatter.spec)
**Change:** Removed the formatter specialization:template<size_t N> struct formatter<const charT[N], charT>;
**Rationale:** The specialization is inconsistent with the design of formatter,
which is intended to be instantiated only with cv-unqualified object types[.](#4.sentence-2)
**Effect on original feature:** Valid C++ 2020 code that instantiated the removed specialization
can become ill-formed[.](#4.sentence-3)

612
cppdraft/diff/cpp23.md Normal file
View File

@@ -0,0 +1,612 @@
[diff.cpp23]
# Annex C (informative) Compatibility [[diff]](./#diff)
## C.1 C++ and ISO C++ 2023 [diff.cpp23]
### [C.1.1](#general) General [[diff.cpp23.general]](diff.cpp23.general)
[1](#general-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L8)
Subclause [diff.cpp23] lists the differences between C++ and
ISO C++ 2023,
by the chapters of this document[.](#general-1.sentence-1)
### [C.1.2](#lex) [[lex]](lex "5Lexical conventions"): lexical conventions [[diff.cpp23.lex]](diff.cpp23.lex)
[1](#lex-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L16)
**Affected subclause:** [[lex.operators]](lex.operators)
**Change:** New operator ^^[.](#lex-1.sentence-1)
**Rationale:** Required for new features[.](#lex-1.sentence-2)
**Effect on original feature:** Valid C++ 2023 code that contains two consecutive ^ tokens
can be ill-formed in this revision of C++[.](#lex-1.sentence-3)
[*Example [1](#lex-example-1)*: struct C { int operator^(int); };int operator^(int (C::*p)(int), C);int i = &C::operator^^C{}; // ill-formed; previously well-formed — *end example*]
[2](#lex-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L32)
**Affected subclause:** [[lex.key]](lex.key)
**Change:** New keywords[.](#lex-2.sentence-1)
**Rationale:** Required for new features[.](#lex-2.sentence-2)
- [(2.1)](#lex-2.1)
The contract_assert keyword
is added to introduce a contract assertion
through an [*assertion-statement*](stmt.contract.assert#nt:assertion-statement "8.9Assertion statement[stmt.contract.assert]") ([[stmt.contract.assert]](stmt.contract.assert "8.9Assertion statement")).
**Effect on original feature:** Valid C++ 2023 code using contract_assert as an identifier
is not valid in this revision of C++[.](#lex-2.sentence-3)
### [C.1.3](#expr) [[expr]](expr "7Expressions"): expressions [[diff.cpp23.expr]](diff.cpp23.expr)
[1](#expr-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L49)
**Affected subclause:** [[expr.arith.conv]](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[.](#expr-1.sentence-1)
**Rationale:** Reinforcing type safety[.](#expr-1.sentence-2)
**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[.](#expr-1.sentence-3)
[*Example [1](#expr-example-1)*: enum E1 { e };enum E2 { f };bool b = e <= 3.7; // ill-formed; previously well-formedint k = f - e; // ill-formed; previously well-formedauto x = true ? e : f; // ill-formed; previously well-formed — *end example*]
[2](#expr-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L69)
**Affected subclauses:** [[expr.rel]](expr.rel) and [[expr.eq]](expr.eq)
**Change:** Comparing two objects of array type is no longer valid[.](#expr-2.sentence-1)
**Rationale:** The old behavior was confusing since it compared not the contents of the two
arrays, but their addresses[.](#expr-2.sentence-2)
**Effect on original feature:** A valid C++ 2023 program directly comparing two array objects is rejected as
ill-formed in this document[.](#expr-2.sentence-3)
[*Example [2](#expr-example-2)*: int arr1[5];int arr2[5];bool same = arr1 == arr2; // ill-formed; previously well-formedbool idem = arr1 == +arr2; // compare addressesbool less = arr1 < +arr2; // compare addresses, unspecified result — *end example*]
[3](#expr-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L88)
**Affected subclause:** [[expr.delete]](expr.delete)
**Change:** Calling delete on a pointer to an incomplete class is ill-formed[.](#expr-3.sentence-1)
**Rationale:** Reduce undefined behavior[.](#expr-3.sentence-2)
**Effect on original feature:** A valid C++ 2023 program that calls delete on an incomplete
class type is ill-formed[.](#expr-3.sentence-3)
[*Example [3](#expr-example-3)*: struct S;
void f(S *p) {delete p; // ill-formed; previously well-formed}struct S {}; — *end example*]
### [C.1.4](#dcl.dcl) [[dcl]](dcl "9Declarations"): declarations [[diff.cpp23.dcl.dcl]](diff.cpp23.dcl.dcl)
[1](#dcl.dcl-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L110)
**Affected subclause:** [[dcl.decl.general]](dcl.decl.general)
**Change:** Introduction of trivially_relocatable_if_eligible andreplaceable_if_eligible as identifiers with special meaning ([[lex.name]](lex.name "5.11Identifiers"))[.](#dcl.dcl-1.sentence-1)
**Rationale:** Support declaration of trivially relocatable and replaceable types ([[class.prop]](class.prop "11.2Properties of classes"))[.](#dcl.dcl-1.sentence-2)
**Effect on original feature:** Valid C++ 2023 code can become ill-formed[.](#dcl.dcl-1.sentence-3)
[*Example [1](#dcl.dcl-example-1)*: struct C {};struct C replaceable_if_eligible {}; // was well-formed (new variable replaceable_if_eligible)// now ill-formed (redefines C) — *end example*]
[2](#dcl.dcl-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L126)
**Affected subclause:** [[dcl.init.list]](dcl.init.list)
**Change:** Pointer comparisons between initializer_list objects' backing arrays
are unspecified[.](#dcl.dcl-2.sentence-1)
**Rationale:** Permit the implementation to store backing arrays in static read-only memory[.](#dcl.dcl-2.sentence-2)
**Effect on original feature:** Valid C++ 2023 code
that relies on the result of pointer comparison between backing arrays
may change behavior[.](#dcl.dcl-2.sentence-3)
[*Example [2](#dcl.dcl-example-2)*: bool ne(std::initializer_list<int> a, std::initializer_list<int> b) {return a.begin() != b.begin() + 1;}bool b = ne({2,3}, {1,2,3}); // unspecified result; previously false — *end example*]
[3](#dcl.dcl-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L145)
**Affected subclause:** [[dcl.array]](dcl.array)
**Change:** Previously, T...[n] would declare a pack of function parameters[.](#dcl.dcl-3.sentence-1)
T...[n] is now a [*pack-index-specifier*](dcl.type.pack.index#nt:pack-index-specifier "9.2.9.4Pack indexing specifier[dcl.type.pack.index]")[.](#dcl.dcl-3.sentence-2)
**Rationale:** Improve the handling of packs[.](#dcl.dcl-3.sentence-3)
**Effect on original feature:** Valid C++ 2023 code that declares a pack of parameters
without specifying a [*declarator-id*](dcl.decl.general#nt:declarator-id "9.3.1General[dcl.decl.general]") becomes ill-formed[.](#dcl.dcl-3.sentence-4)
[*Example [3](#dcl.dcl-example-3)*: template <typename... T>void f(T... [1]);template <typename... T>void g(T... ptr[1]);int main() { f<int, double>(nullptr, nullptr); // ill-formed, previously void f<int, double>(int [1], double [1]) g<int, double>(nullptr, nullptr); // ok} — *end example*]
[4](#dcl.dcl-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L167)
**Affected subclause:** [[dcl.attr.grammar]](dcl.attr.grammar)
**Change:** New token :][.](#dcl.dcl-4.sentence-1)
**Rationale:** Required for new features[.](#dcl.dcl-4.sentence-2)
**Effect on original feature:** Valid C++ 2023 code that contained an [*attribute-specifier*](dcl.attr.grammar#nt:attribute-specifier "9.13.1Attribute syntax and semantics[dcl.attr.grammar]") with an [*attribute-using-prefix*](dcl.attr.grammar#nt:attribute-using-prefix "9.13.1Attribute syntax and semantics[dcl.attr.grammar]") but no attributes and no whitespace is ill-formed in this revision of C++[.](#dcl.dcl-4.sentence-3)
[*Example [4](#dcl.dcl-example-4)*: struct [[using CC:]] C; // ill-formed; previously well-formedstruct [[using DD: ]] D; // OK — *end example*]
### [C.1.5](#temp) [[temp]](temp "13Templates"): templates [[diff.cpp23.temp]](diff.cpp23.temp)
[1](#temp-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L185)
**Affected subclause:** [[temp.constr]](temp.constr)
**Change:** Some atomic constraints become fold expanded constraints[.](#temp-1.sentence-1)
**Rationale:** Permit the subsumption of fold expressions[.](#temp-1.sentence-2)
**Effect on original feature:** Valid C++ 2023 code may become ill-formed[.](#temp-1.sentence-3)
[*Example [1](#temp-example-1)*: template <typename ...V> struct A;struct S {static constexpr int compare(const S&) { return 1; }};
template <typename ...T, typename ...U>void f(A<T ...> *, A<U ...> *)requires (T::compare(U{}) && ...); // was well-formed (atomic constraint of type bool),// now ill-formed (results in an atomic constraint of type int)void g(A<S, S> *ap) { f(ap, ap);} — *end example*]
[2](#temp-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L209)
**Affected subclause:** [[temp.deduct.call]](temp.deduct.call)
**Change:** Template argument deduction from overload sets succeeds in more cases[.](#temp-2.sentence-1)
**Rationale:** Allow consideration of constraints to disambiguate overload sets
used as parameters in function calls[.](#temp-2.sentence-2)
**Effect on original feature:** Valid C++ 2023 code may become ill-formed[.](#temp-2.sentence-3)
[*Example [2](#temp-example-2)*: template <typename T>void f(T &&, void (*)(T &&));
void g(int &); // #1inline namespace A {void g(short &&); // #2}inline namespace B {void g(short &&); // #3}void q() {int x;
f(x, g); // ill-formed; previously well-formed, deducing T = int&}
There is no change to the applicable deduction rules for
the individual g candidates:
Type deduction from #1 does not succeed;
type deductions from #2 and #3 both succeed[.](#temp-2.sentence-4)
— *end example*]
### [C.1.6](#library) [[library]](library "16Library introduction"): library introduction [[diff.cpp23.library]](diff.cpp23.library)
[1](#library-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L243)
**Affected subclause:** [[headers]](headers)
**Change:** New headers[.](#library-1.sentence-1)
**Rationale:** New functionality[.](#library-1.sentence-2)
**Effect on original feature:** The following C++ headers are new:[<contracts>](contracts.syn#header:%3ccontracts%3e "17.10.1Header <contracts> synopsis[contracts.syn]"),[<debugging>](debugging.syn#header:%3cdebugging%3e "19.7.2Header <debugging> synopsis[debugging.syn]"),[<hazard_pointer>](hazard.pointer.syn#header:%3chazard_pointer%3e "32.11.3.2Header <hazard_­pointer> synopsis[hazard.pointer.syn]"),[<hive>](hive.syn#header:%3chive%3e "23.3.8Header <hive> synopsis[hive.syn]"),[<inplace_vector>](inplace.vector.syn#header:%3cinplace_vector%3e "23.3.15Header <inplace_­vector> synopsis[inplace.vector.syn]"),[<linalg>](linalg.syn#header:%3clinalg%3e "29.9.2Header <linalg> synopsis[linalg.syn]"),[<meta>](meta.syn#header:%3cmeta%3e "21.4.1Header <meta> synopsis[meta.syn]"),[<rcu>](rcu.syn#header:%3crcu%3e "32.11.2.2Header <rcu> synopsis[rcu.syn]"),[<simd>](simd.syn#header:%3csimd%3e "29.10.3Header <simd> synopsis[simd.syn]"),[<stdbit.h>](stdbit.h.syn#header:%3cstdbit.h%3e "22.12Header <stdbit.h> synopsis[stdbit.h.syn]"),[<stdckdint.h>](stdckdint.h.syn#header:%3cstdckdint.h%3e "29.11.1Header <stdckdint.h> synopsis[stdckdint.h.syn]"), and[<text_encoding>](text.encoding.syn#header:%3ctext_encoding%3e "28.4.1Header <text_­encoding> synopsis[text.encoding.syn]")[.](#library-1.sentence-3)
Valid C++ 2023 code that #includes headers with these names may be
invalid in this revision of C++[.](#library-1.sentence-4)
[2](#library-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L265)
**Affected subclause:** [[res.on.macro.definitions]](res.on.macro.definitions)
**Change:** Additional restrictions on macro names[.](#library-2.sentence-1)
**Rationale:** Avoid hard to diagnose or non-portable constructs[.](#library-2.sentence-2)
**Effect on original feature:** Names of special identifiers may not be used as macro names[.](#library-2.sentence-3)
Valid C++ 2023 code that defines replaceable_if_eligible ortrivially_relocatable_if_eligible as macros is invalid
in this revision of C++[.](#library-2.sentence-4)
### [C.1.7](#mem) [[mem]](mem "20Memory management library"): memory management library [[diff.cpp23.mem]](diff.cpp23.mem)
[1](#mem-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L278)
**Affected subclause:** [[c.malloc]](c.malloc)
**Change:** Calling realloc with a non-null pointer and zero size
has erroneous behavior[.](#mem-1.sentence-1)
**Rationale:** The C standard library does not define this behavior[.](#mem-1.sentence-2)
**Effect on original feature:** Valid C++ 2023 code that calls realloc with a non-null pointer and a size of zero is erroneous and may change behavior[.](#mem-1.sentence-3)
### [C.1.8](#containers) [[containers]](containers "23Containers library"): containers library [[diff.cpp23.containers]](diff.cpp23.containers)
[1](#containers-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L290)
**Affected subclause:** [[span.overview]](span.overview)
**Change:** span<const T> is constructible from initializer_list<T>[.](#containers-1.sentence-1)
**Rationale:** Permit passing a braced initializer list to a function taking span[.](#containers-1.sentence-2)
**Effect on original feature:** Valid C++ 2023 code that relies on the lack of this constructor
may refuse to compile, or change behavior in this revision of C++[.](#containers-1.sentence-3)
[*Example [1](#containers-example-1)*: void one(pair<int, int>); // #1void one(span<const int>); // #2void t1() { one({1, 2}); } // ambiguous between #1 and #2; previously called #1void two(span<const int, 2>);void t2() { two({{1, 2}}); } // ill-formed; previously well-formedvoid *a[10];int x = span<void* const>{a, 0}.size(); // x is 2; previously 0 any b[10];int y = span<const any>{b, b + 10}.size(); // y is 2; previously 10 — *end example*]
### [C.1.9](#strings) [[strings]](strings "27Strings library"): strings library [[diff.cpp23.strings]](diff.cpp23.strings)
[1](#strings-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L316)
**Affected subclause:** [[string.conversions]](string.conversions)
**Change:** Output of floating-point overloads of to_string and to_wstring[.](#strings-1.sentence-1)
**Rationale:** Prevent loss of information and improve consistency with other formatting
facilities[.](#strings-1.sentence-2)
**Effect on original feature:** to_string and to_wstring function calls that take
floating-point arguments may produce a different output[.](#strings-1.sentence-3)
[*Example [1](#strings-example-1)*: auto s = std::to_string(1e-7); // "1e-07"// previously "0.000000" with '.' possibly// changed according to the global C locale — *end example*]
### [C.1.10](#io) [[input.output]](input.output "31Input/output library"): input/output library [[diff.cpp23.io]](diff.cpp23.io)
[1](#io-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L335)
**Affected subclause:** [[istream.unformatted]](istream.unformatted)
**Change:** Overloaded std::basic_istream<char, traits>::ignore[.](#io-1.sentence-1)
**Rationale:** Allow char values to be used as delimiters[.](#io-1.sentence-2)
**Effect on original feature:** Calls to istream::ignore with a second argument of char type
can change behavior[.](#io-1.sentence-3)
Calls to istream::ignore with a second argument that is neitherint nor char type can become ill-formed[.](#io-1.sentence-4)
[*Example [1](#io-example-1)*: std::istringstream in("\xF0\x9F\xA4\xA1 Clown Face");
in.ignore(100, '\xA1'); // ignore up to '\xA1' delimiter,// previously might have ignored to EOF in.ignore(100, -1L); // ambiguous overload,// previously equivalent to (int)-1L — *end example*]
### [C.1.11](#depr) [[depr]](depr "Annex D(normative)Compatibility features"): compatibility features [[diff.cpp23.depr]](diff.cpp23.depr)
[1](#depr-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L358)
**Change:** Remove the type alias allocator<T>::is_always_equal[.](#depr-1.sentence-1)
**Rationale:** Non-empty allocator classes derived from allocator needed to explicitly
define an is_always_equal member type so that allocator_traits would not use the one from the allocator base class[.](#depr-1.sentence-2)
**Effect on original feature:** It is simpler to correctly define an allocator class with an allocator base
class[.](#depr-1.sentence-3)
[*Example [1](#depr-example-1)*: template <class T>struct MyAlloc : allocator<T> {int tag;};
static_assert(!allocator_traits<MyAlloc<int>>::is_always_equal); // Error in C++ 2023,// OK in C++ 2026 — *end example*]
[2](#depr-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L380)
**Change:** Removal of atomic access API for shared_ptr objects[.](#depr-2.sentence-1)
**Rationale:** The old behavior was brittle[.](#depr-2.sentence-2)
shared_ptr objects using the old API were
not protected by the type system, and certain interactions with code not using
this API would, in some cases, silently produce undefined behavior[.](#depr-2.sentence-3)
A complete
type-safe replacement is provided in the form of atomic<shared_ptr<T>>[.](#depr-2.sentence-4)
**Effect on original feature:** A valid C++ 2023 program that relies on the presence of the removed functions
may fail to compile[.](#depr-2.sentence-5)
[3](#depr-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L392)
**Change:** Remove the basic_string::reserve() overload with no parameters[.](#depr-3.sentence-1)
**Rationale:** The overload of reserve with no parameters is redundant[.](#depr-3.sentence-2)
The shrink_to_fit member function can be used instead[.](#depr-3.sentence-3)
**Effect on original feature:** A valid C++ 2023 program that calls reserve() on a basic_string object may fail to compile[.](#depr-3.sentence-4)
The old functionality can be achieved by calling shrink_to_fit() instead,
or the function call can be safely eliminated with no side effects[.](#depr-3.sentence-5)
[4](#depr-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L404)
**Change:** Remove header <codecvt> and all its contents[.](#depr-4.sentence-1)
**Rationale:** The header has been deprecated for the previous three editions of this document
and no longer implements the current Unicode standard, supporting only the
obsolete UCS-2 encoding[.](#depr-4.sentence-2)
Ongoing support is at implementer's discretion,
exercising freedoms granted by [[zombie.names]](zombie.names "16.4.5.3.2Zombie names")[.](#depr-4.sentence-3)
**Effect on original feature:** A valid C++ 2023 program #include-ing the header or importing the
header unit may fail to compile[.](#depr-4.sentence-4)
Code that uses any of the following names by
importing the standard library modules may fail to compile:
- [(4.1)](#depr-4.1)
codecvt_mode,
- [(4.2)](#depr-4.2)
codecvt_utf16,
- [(4.3)](#depr-4.3)
codecvt_utf8,
- [(4.4)](#depr-4.4)
codecvt_utf8_utf16,
- [(4.5)](#depr-4.5)
consume_header,
- [(4.6)](#depr-4.6)
generate_header, and
- [(4.7)](#depr-4.7)
little_endian[.](#depr-4.sentence-5)
[5](#depr-5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L427)
**Change:** Remove header <strstream> and all its contents[.](#depr-5.sentence-1)
**Rationale:** The header has been deprecated since the original C++ standard; the[<spanstream>](span.streams.overview#header:%3cspanstream%3e "31.9.1Overview[span.streams.overview]") header provides an updated, safer facility[.](#depr-5.sentence-2)
Ongoing support is at implementer's discretion,
exercising freedoms granted by [[zombie.names]](zombie.names "16.4.5.3.2Zombie names")[.](#depr-5.sentence-3)
**Effect on original feature:** A valid C++ 2023 program #include-ing the header or importing the
header unit may become ill-formed[.](#depr-5.sentence-4)
Code that uses any of the following classes
by importing one of the standard library modules may become ill-formed:
- [(5.1)](#depr-5.1)
istrstream
- [(5.2)](#depr-5.2)
ostrstream
- [(5.3)](#depr-5.3)
strstream
- [(5.4)](#depr-5.4)
strstreambuf
[6](#depr-6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L446)
**Change:** Remove convenience interfaces wstring_convert andwbuffer_convert[.](#depr-6.sentence-1)
**Rationale:** These features were underspecified with no clear error reporting mechanism and
were deprecated for the last three editions of this document[.](#depr-6.sentence-2)
Ongoing support is at implementer's discretion,
exercising freedoms granted by [[zombie.names]](zombie.names "16.4.5.3.2Zombie names")[.](#depr-6.sentence-3)
**Effect on original feature:** A valid C++ 2023 program using these interfaces may become ill-formed[.](#depr-6.sentence-4)

View File

@@ -0,0 +1,29 @@
[diff.cpp23.containers]
# Annex C (informative) Compatibility [[diff]](./#diff)
## C.1 C++ and ISO C++ 2023 [[diff.cpp23]](diff.cpp23#containers)
### C.1.8 [[containers]](containers "23Containers library"): containers library [diff.cpp23.containers]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L290)
**Affected subclause:** [[span.overview]](span.overview)
**Change:** span<const T> is constructible from initializer_list<T>[.](#1.sentence-1)
**Rationale:** Permit passing a braced initializer list to a function taking span[.](#1.sentence-2)
**Effect on original feature:** Valid C++ 2023 code that relies on the lack of this constructor
may refuse to compile, or change behavior in this revision of C++[.](#1.sentence-3)
[*Example [1](#example-1)*: void one(pair<int, int>); // #1void one(span<const int>); // #2void t1() { one({1, 2}); } // ambiguous between #1 and #2; previously called #1void two(span<const int, 2>);void t2() { two({{1, 2}}); } // ill-formed; previously well-formedvoid *a[10];int x = span<void* const>{a, 0}.size(); // x is 2; previously 0 any b[10];int y = span<const any>{b, b + 10}.size(); // y is 2; previously 10 — *end example*]

View File

@@ -0,0 +1,97 @@
[diff.cpp23.dcl.dcl]
# Annex C (informative) Compatibility [[diff]](./#diff)
## C.1 C++ and ISO C++ 2023 [[diff.cpp23]](diff.cpp23#dcl.dcl)
### C.1.4 [[dcl]](dcl "9Declarations"): declarations [diff.cpp23.dcl.dcl]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L110)
**Affected subclause:** [[dcl.decl.general]](dcl.decl.general)
**Change:** Introduction of trivially_relocatable_if_eligible andreplaceable_if_eligible as identifiers with special meaning ([[lex.name]](lex.name "5.11Identifiers"))[.](#1.sentence-1)
**Rationale:** Support declaration of trivially relocatable and replaceable types ([[class.prop]](class.prop "11.2Properties of classes"))[.](#1.sentence-2)
**Effect on original feature:** Valid C++ 2023 code can become ill-formed[.](#1.sentence-3)
[*Example [1](#example-1)*: struct C {};struct C replaceable_if_eligible {}; // was well-formed (new variable replaceable_if_eligible)// now ill-formed (redefines C) — *end example*]
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L126)
**Affected subclause:** [[dcl.init.list]](dcl.init.list)
**Change:** Pointer comparisons between initializer_list objects' backing arrays
are unspecified[.](#2.sentence-1)
**Rationale:** Permit the implementation to store backing arrays in static read-only memory[.](#2.sentence-2)
**Effect on original feature:** Valid C++ 2023 code
that relies on the result of pointer comparison between backing arrays
may change behavior[.](#2.sentence-3)
[*Example [2](#example-2)*: bool ne(std::initializer_list<int> a, std::initializer_list<int> b) {return a.begin() != b.begin() + 1;}bool b = ne({2,3}, {1,2,3}); // unspecified result; previously false — *end example*]
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L145)
**Affected subclause:** [[dcl.array]](dcl.array)
**Change:** Previously, T...[n] would declare a pack of function parameters[.](#3.sentence-1)
T...[n] is now a [*pack-index-specifier*](dcl.type.pack.index#nt:pack-index-specifier "9.2.9.4Pack indexing specifier[dcl.type.pack.index]")[.](#3.sentence-2)
**Rationale:** Improve the handling of packs[.](#3.sentence-3)
**Effect on original feature:** Valid C++ 2023 code that declares a pack of parameters
without specifying a [*declarator-id*](dcl.decl.general#nt:declarator-id "9.3.1General[dcl.decl.general]") becomes ill-formed[.](#3.sentence-4)
[*Example [3](#example-3)*: template <typename... T>void f(T... [1]);template <typename... T>void g(T... ptr[1]);int main() { f<int, double>(nullptr, nullptr); // ill-formed, previously void f<int, double>(int [1], double [1]) g<int, double>(nullptr, nullptr); // ok} — *end example*]
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L167)
**Affected subclause:** [[dcl.attr.grammar]](dcl.attr.grammar)
**Change:** New token :][.](#4.sentence-1)
**Rationale:** Required for new features[.](#4.sentence-2)
**Effect on original feature:** Valid C++ 2023 code that contained an [*attribute-specifier*](dcl.attr.grammar#nt:attribute-specifier "9.13.1Attribute syntax and semantics[dcl.attr.grammar]") with an [*attribute-using-prefix*](dcl.attr.grammar#nt:attribute-using-prefix "9.13.1Attribute syntax and semantics[dcl.attr.grammar]") but no attributes and no whitespace is ill-formed in this revision of C++[.](#4.sentence-3)
[*Example [4](#example-4)*: struct [[using CC:]] C; // ill-formed; previously well-formedstruct [[using DD: ]] D; // OK — *end example*]

186
cppdraft/diff/cpp23/depr.md Normal file
View File

@@ -0,0 +1,186 @@
[diff.cpp23.depr]
# Annex C (informative) Compatibility [[diff]](./#diff)
## C.1 C++ and ISO C++ 2023 [[diff.cpp23]](diff.cpp23#depr)
### C.1.11 [[depr]](depr "Annex D(normative)Compatibility features"): compatibility features [diff.cpp23.depr]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L358)
**Change:** Remove the type alias allocator<T>::is_always_equal[.](#1.sentence-1)
**Rationale:** Non-empty allocator classes derived from allocator needed to explicitly
define an is_always_equal member type so that allocator_traits would not use the one from the allocator base class[.](#1.sentence-2)
**Effect on original feature:** It is simpler to correctly define an allocator class with an allocator base
class[.](#1.sentence-3)
[*Example [1](#example-1)*: template <class T>struct MyAlloc : allocator<T> {int tag;};
static_assert(!allocator_traits<MyAlloc<int>>::is_always_equal); // Error in C++ 2023,// OK in C++ 2026 — *end example*]
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L380)
**Change:** Removal of atomic access API for shared_ptr objects[.](#2.sentence-1)
**Rationale:** The old behavior was brittle[.](#2.sentence-2)
shared_ptr objects using the old API were
not protected by the type system, and certain interactions with code not using
this API would, in some cases, silently produce undefined behavior[.](#2.sentence-3)
A complete
type-safe replacement is provided in the form of atomic<shared_ptr<T>>[.](#2.sentence-4)
**Effect on original feature:** A valid C++ 2023 program that relies on the presence of the removed functions
may fail to compile[.](#2.sentence-5)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L392)
**Change:** Remove the basic_string::reserve() overload with no parameters[.](#3.sentence-1)
**Rationale:** The overload of reserve with no parameters is redundant[.](#3.sentence-2)
The shrink_to_fit member function can be used instead[.](#3.sentence-3)
**Effect on original feature:** A valid C++ 2023 program that calls reserve() on a basic_string object may fail to compile[.](#3.sentence-4)
The old functionality can be achieved by calling shrink_to_fit() instead,
or the function call can be safely eliminated with no side effects[.](#3.sentence-5)
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L404)
**Change:** Remove header <codecvt> and all its contents[.](#4.sentence-1)
**Rationale:** The header has been deprecated for the previous three editions of this document
and no longer implements the current Unicode standard, supporting only the
obsolete UCS-2 encoding[.](#4.sentence-2)
Ongoing support is at implementer's discretion,
exercising freedoms granted by [[zombie.names]](zombie.names "16.4.5.3.2Zombie names")[.](#4.sentence-3)
**Effect on original feature:** A valid C++ 2023 program #include-ing the header or importing the
header unit may fail to compile[.](#4.sentence-4)
Code that uses any of the following names by
importing the standard library modules may fail to compile:
- [(4.1)](#4.1)
codecvt_mode,
- [(4.2)](#4.2)
codecvt_utf16,
- [(4.3)](#4.3)
codecvt_utf8,
- [(4.4)](#4.4)
codecvt_utf8_utf16,
- [(4.5)](#4.5)
consume_header,
- [(4.6)](#4.6)
generate_header, and
- [(4.7)](#4.7)
little_endian[.](#4.sentence-5)
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L427)
**Change:** Remove header <strstream> and all its contents[.](#5.sentence-1)
**Rationale:** The header has been deprecated since the original C++ standard; the[<spanstream>](span.streams.overview#header:%3cspanstream%3e "31.9.1Overview[span.streams.overview]") header provides an updated, safer facility[.](#5.sentence-2)
Ongoing support is at implementer's discretion,
exercising freedoms granted by [[zombie.names]](zombie.names "16.4.5.3.2Zombie names")[.](#5.sentence-3)
**Effect on original feature:** A valid C++ 2023 program #include-ing the header or importing the
header unit may become ill-formed[.](#5.sentence-4)
Code that uses any of the following classes
by importing one of the standard library modules may become ill-formed:
- [(5.1)](#5.1)
istrstream
- [(5.2)](#5.2)
ostrstream
- [(5.3)](#5.3)
strstream
- [(5.4)](#5.4)
strstreambuf
[6](#6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L446)
**Change:** Remove convenience interfaces wstring_convert andwbuffer_convert[.](#6.sentence-1)
**Rationale:** These features were underspecified with no clear error reporting mechanism and
were deprecated for the last three editions of this document[.](#6.sentence-2)
Ongoing support is at implementer's discretion,
exercising freedoms granted by [[zombie.names]](zombie.names "16.4.5.3.2Zombie names")[.](#6.sentence-3)
**Effect on original feature:** A valid C++ 2023 program using these interfaces may become ill-formed[.](#6.sentence-4)

View File

@@ -0,0 +1,78 @@
[diff.cpp23.expr]
# Annex C (informative) Compatibility [[diff]](./#diff)
## C.1 C++ and ISO C++ 2023 [[diff.cpp23]](diff.cpp23#expr)
### C.1.3 [[expr]](expr "7Expressions"): expressions [diff.cpp23.expr]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L49)
**Affected subclause:** [[expr.arith.conv]](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[.](#1.sentence-1)
**Rationale:** Reinforcing type safety[.](#1.sentence-2)
**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[.](#1.sentence-3)
[*Example [1](#example-1)*: enum E1 { e };enum E2 { f };bool b = e <= 3.7; // ill-formed; previously well-formedint k = f - e; // ill-formed; previously well-formedauto x = true ? e : f; // ill-formed; previously well-formed — *end example*]
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L69)
**Affected subclauses:** [[expr.rel]](expr.rel) and [[expr.eq]](expr.eq)
**Change:** Comparing two objects of array type is no longer valid[.](#2.sentence-1)
**Rationale:** The old behavior was confusing since it compared not the contents of the two
arrays, but their addresses[.](#2.sentence-2)
**Effect on original feature:** A valid C++ 2023 program directly comparing two array objects is rejected as
ill-formed in this document[.](#2.sentence-3)
[*Example [2](#example-2)*: int arr1[5];int arr2[5];bool same = arr1 == arr2; // ill-formed; previously well-formedbool idem = arr1 == +arr2; // compare addressesbool less = arr1 < +arr2; // compare addresses, unspecified result — *end example*]
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L88)
**Affected subclause:** [[expr.delete]](expr.delete)
**Change:** Calling delete on a pointer to an incomplete class is ill-formed[.](#3.sentence-1)
**Rationale:** Reduce undefined behavior[.](#3.sentence-2)
**Effect on original feature:** A valid C++ 2023 program that calls delete on an incomplete
class type is ill-formed[.](#3.sentence-3)
[*Example [3](#example-3)*: struct S;
void f(S *p) {delete p; // ill-formed; previously well-formed}struct S {}; — *end example*]

View File

@@ -0,0 +1,15 @@
[diff.cpp23.general]
# Annex C (informative) Compatibility [[diff]](./#diff)
## C.1 C++ and ISO C++ 2023 [[diff.cpp23]](diff.cpp23#general)
### C.1.1 General [diff.cpp23.general]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L8)
Subclause [[diff.cpp23]](diff.cpp23 "C.1C++ and ISO C++ 2023") lists the differences between C++ and
ISO C++ 2023,
by the chapters of this document[.](#1.sentence-1)

32
cppdraft/diff/cpp23/io.md Normal file
View File

@@ -0,0 +1,32 @@
[diff.cpp23.io]
# Annex C (informative) Compatibility [[diff]](./#diff)
## C.1 C++ and ISO C++ 2023 [[diff.cpp23]](diff.cpp23#io)
### C.1.10 [[input.output]](input.output "31Input/output library"): input/output library [diff.cpp23.io]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L335)
**Affected subclause:** [[istream.unformatted]](istream.unformatted)
**Change:** Overloaded std::basic_istream<char, traits>::ignore[.](#1.sentence-1)
**Rationale:** Allow char values to be used as delimiters[.](#1.sentence-2)
**Effect on original feature:** Calls to istream::ignore with a second argument of char type
can change behavior[.](#1.sentence-3)
Calls to istream::ignore with a second argument that is neitherint nor char type can become ill-formed[.](#1.sentence-4)
[*Example [1](#example-1)*: std::istringstream in("\xF0\x9F\xA4\xA1 Clown Face");
in.ignore(100, '\xA1'); // ignore up to '\xA1' delimiter,// previously might have ignored to EOF in.ignore(100, -1L); // ambiguous overload,// previously equivalent to (int)-1L — *end example*]

View File

@@ -0,0 +1,55 @@
[diff.cpp23.lex]
# Annex C (informative) Compatibility [[diff]](./#diff)
## C.1 C++ and ISO C++ 2023 [[diff.cpp23]](diff.cpp23#lex)
### C.1.2 [[lex]](lex "5Lexical conventions"): lexical conventions [diff.cpp23.lex]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L16)
**Affected subclause:** [[lex.operators]](lex.operators)
**Change:** New operator ^^[.](#1.sentence-1)
**Rationale:** Required for new features[.](#1.sentence-2)
**Effect on original feature:** Valid C++ 2023 code that contains two consecutive ^ tokens
can be ill-formed in this revision of C++[.](#1.sentence-3)
[*Example [1](#example-1)*: struct C { int operator^(int); };int operator^(int (C::*p)(int), C);int i = &C::operator^^C{}; // ill-formed; previously well-formed — *end example*]
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L32)
**Affected subclause:** [[lex.key]](lex.key)
**Change:** New keywords[.](#2.sentence-1)
**Rationale:** Required for new features[.](#2.sentence-2)
- [(2.1)](#2.1)
The contract_assert keyword
is added to introduce a contract assertion
through an [*assertion-statement*](stmt.contract.assert#nt:assertion-statement "8.9Assertion statement[stmt.contract.assert]") ([[stmt.contract.assert]](stmt.contract.assert "8.9Assertion statement")).
**Effect on original feature:** Valid C++ 2023 code using contract_assert as an identifier
is not valid in this revision of C++[.](#2.sentence-3)

View File

@@ -0,0 +1,51 @@
[diff.cpp23.library]
# Annex C (informative) Compatibility [[diff]](./#diff)
## C.1 C++ and ISO C++ 2023 [[diff.cpp23]](diff.cpp23#library)
### C.1.6 [[library]](library "16Library introduction"): library introduction [diff.cpp23.library]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L243)
**Affected subclause:** [[headers]](headers)
**Change:** New headers[.](#1.sentence-1)
**Rationale:** New functionality[.](#1.sentence-2)
**Effect on original feature:** The following C++ headers are new:[<contracts>](contracts.syn#header:%3ccontracts%3e "17.10.1Header <contracts> synopsis[contracts.syn]"),[<debugging>](debugging.syn#header:%3cdebugging%3e "19.7.2Header <debugging> synopsis[debugging.syn]"),[<hazard_pointer>](hazard.pointer.syn#header:%3chazard_pointer%3e "32.11.3.2Header <hazard_­pointer> synopsis[hazard.pointer.syn]"),[<hive>](hive.syn#header:%3chive%3e "23.3.8Header <hive> synopsis[hive.syn]"),[<inplace_vector>](inplace.vector.syn#header:%3cinplace_vector%3e "23.3.15Header <inplace_­vector> synopsis[inplace.vector.syn]"),[<linalg>](linalg.syn#header:%3clinalg%3e "29.9.2Header <linalg> synopsis[linalg.syn]"),[<meta>](meta.syn#header:%3cmeta%3e "21.4.1Header <meta> synopsis[meta.syn]"),[<rcu>](rcu.syn#header:%3crcu%3e "32.11.2.2Header <rcu> synopsis[rcu.syn]"),[<simd>](simd.syn#header:%3csimd%3e "29.10.3Header <simd> synopsis[simd.syn]"),[<stdbit.h>](stdbit.h.syn#header:%3cstdbit.h%3e "22.12Header <stdbit.h> synopsis[stdbit.h.syn]"),[<stdckdint.h>](stdckdint.h.syn#header:%3cstdckdint.h%3e "29.11.1Header <stdckdint.h> synopsis[stdckdint.h.syn]"), and[<text_encoding>](text.encoding.syn#header:%3ctext_encoding%3e "28.4.1Header <text_­encoding> synopsis[text.encoding.syn]")[.](#1.sentence-3)
Valid C++ 2023 code that #includes headers with these names may be
invalid in this revision of C++[.](#1.sentence-4)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L265)
**Affected subclause:** [[res.on.macro.definitions]](res.on.macro.definitions)
**Change:** Additional restrictions on macro names[.](#2.sentence-1)
**Rationale:** Avoid hard to diagnose or non-portable constructs[.](#2.sentence-2)
**Effect on original feature:** Names of special identifiers may not be used as macro names[.](#2.sentence-3)
Valid C++ 2023 code that defines replaceable_if_eligible ortrivially_relocatable_if_eligible as macros is invalid
in this revision of C++[.](#2.sentence-4)

View File

@@ -0,0 +1,27 @@
[diff.cpp23.mem]
# Annex C (informative) Compatibility [[diff]](./#diff)
## C.1 C++ and ISO C++ 2023 [[diff.cpp23]](diff.cpp23#mem)
### C.1.7 [[mem]](mem "20Memory management library"): memory management library [diff.cpp23.mem]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L278)
**Affected subclause:** [[c.malloc]](c.malloc)
**Change:** Calling realloc with a non-null pointer and zero size
has erroneous behavior[.](#1.sentence-1)
**Rationale:** The C standard library does not define this behavior[.](#1.sentence-2)
**Effect on original feature:** Valid C++ 2023 code that calls realloc with a non-null pointer and a size of zero is erroneous and may change behavior[.](#1.sentence-3)

View File

@@ -0,0 +1,30 @@
[diff.cpp23.strings]
# Annex C (informative) Compatibility [[diff]](./#diff)
## C.1 C++ and ISO C++ 2023 [[diff.cpp23]](diff.cpp23#strings)
### C.1.9 [[strings]](strings "27Strings library"): strings library [diff.cpp23.strings]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L316)
**Affected subclause:** [[string.conversions]](string.conversions)
**Change:** Output of floating-point overloads of to_string and to_wstring[.](#1.sentence-1)
**Rationale:** Prevent loss of information and improve consistency with other formatting
facilities[.](#1.sentence-2)
**Effect on original feature:** to_string and to_wstring function calls that take
floating-point arguments may produce a different output[.](#1.sentence-3)
[*Example [1](#example-1)*: auto s = std::to_string(1e-7); // "1e-07"// previously "0.000000" with '.' possibly// changed according to the global C locale — *end example*]

View File

@@ -0,0 +1,62 @@
[diff.cpp23.temp]
# Annex C (informative) Compatibility [[diff]](./#diff)
## C.1 C++ and ISO C++ 2023 [[diff.cpp23]](diff.cpp23#temp)
### C.1.5 [[temp]](temp "13Templates"): templates [diff.cpp23.temp]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L185)
**Affected subclause:** [[temp.constr]](temp.constr)
**Change:** Some atomic constraints become fold expanded constraints[.](#1.sentence-1)
**Rationale:** Permit the subsumption of fold expressions[.](#1.sentence-2)
**Effect on original feature:** Valid C++ 2023 code may become ill-formed[.](#1.sentence-3)
[*Example [1](#example-1)*: template <typename ...V> struct A;struct S {static constexpr int compare(const S&) { return 1; }};
template <typename ...T, typename ...U>void f(A<T ...> *, A<U ...> *)requires (T::compare(U{}) && ...); // was well-formed (atomic constraint of type bool),// now ill-formed (results in an atomic constraint of type int)void g(A<S, S> *ap) { f(ap, ap);} — *end example*]
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L209)
**Affected subclause:** [[temp.deduct.call]](temp.deduct.call)
**Change:** Template argument deduction from overload sets succeeds in more cases[.](#2.sentence-1)
**Rationale:** Allow consideration of constraints to disambiguate overload sets
used as parameters in function calls[.](#2.sentence-2)
**Effect on original feature:** Valid C++ 2023 code may become ill-formed[.](#2.sentence-3)
[*Example [2](#example-2)*: template <typename T>void f(T &&, void (*)(T &&));
void g(int &); // #1inline namespace A {void g(short &&); // #2}inline namespace B {void g(short &&); // #3}void q() {int x;
f(x, g); // ill-formed; previously well-formed, deducing T = int&}
There is no change to the applicable deduction rules for
the individual g candidates:
Type deduction from #1 does not succeed;
type deductions from #2 and #3 both succeed[.](#2.sentence-4)
— *end example*]

494
cppdraft/diff/dcl.md Normal file
View File

@@ -0,0 +1,494 @@
[diff.dcl]
# Annex C (informative) Compatibility [[diff]](./#diff)
## C.7 C++ and C [[diff.iso]](diff.iso#diff.dcl)
### C.7.6 [[dcl]](dcl "9Declarations"): declarations [diff.dcl]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L3168)
**Affected subclause:** [[dcl.stc]](dcl.stc)
**Change:** In C++, the static or extern specifiers can only be applied to names of objects or functions[.](#1.sentence-1)
Using these specifiers with type declarations is illegal in C++[.](#1.sentence-2)
In C, these specifiers are ignored when used on type declarations[.](#1.sentence-3)
[*Example [1](#example-1)*: static struct S { // valid C, invalid in C++int i;}; — *end example*]
**Rationale:** Storage class specifiers don't have any meaning when associated
with a type[.](#1.sentence-4)
In C++, class members can be declared with the static storage
class specifier[.](#1.sentence-5)
Storage class specifiers on type
declarations can be confusing for users[.](#1.sentence-6)
**Effect on original feature:** Deletion of semantically well-defined feature[.](#1.sentence-7)
**Difficulty of converting:** Syntactic transformation[.](#1.sentence-8)
**How widely used:** Seldom[.](#1.sentence-9)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L3196)
**Affected subclause:** [[dcl.stc]](dcl.stc)
**Change:** In C++, register is not a storage class specifier[.](#2.sentence-1)
**Rationale:** The storage class specifier had no effect in C++[.](#2.sentence-2)
**Effect on original feature:** Deletion of semantically well-defined feature[.](#2.sentence-3)
**Difficulty of converting:** Syntactic transformation[.](#2.sentence-4)
**How widely used:** Common[.](#2.sentence-5)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L3208)
**Affected subclause:** [[dcl.typedef]](dcl.typedef)
**Change:** A C++ [*typedef-name*](dcl.typedef#nt:typedef-name "9.2.4The typedef specifier[dcl.typedef]") must be different from any class type name declared
in the same scope (except if the typedef is a synonym of the class name with the
same name)[.](#3.sentence-1)
In C, a [*typedef-name*](dcl.typedef#nt:typedef-name "9.2.4The typedef specifier[dcl.typedef]") and a struct tag name declared in the same scope
can have the same name (because they have different name spaces)[.](#3.sentence-2)
[*Example [2](#example-2)*: typedef struct name1 { /* ... */ } name1; // valid C and C++struct name { /* ... */ };typedef int name; // valid C, invalid C++ — *end example*]
**Rationale:** For ease of use, C++ doesn't require that a type name be prefixed
with the keywords class, struct or union when used in object
declarations or type casts[.](#3.sentence-3)
[*Example [3](#example-3)*: class name { /* ... */ };
name i; // i has type class name — *end example*]
**Effect on original feature:** Deletion of semantically well-defined feature[.](#3.sentence-4)
**Difficulty of converting:** Semantic transformation[.](#3.sentence-5)
One of the 2 types has to be renamed[.](#3.sentence-6)
**How widely used:** Seldom[.](#3.sentence-7)
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L3243)
**Affected subclause:** [[dcl.type]](dcl.type) [see also [[basic.link]](basic.link "6.7Program and linkage")]
**Change:** Const objects must be initialized in C++ but can be left uninitialized in C[.](#4.sentence-2)
**Rationale:** A const object cannot be assigned to so it must be initialized
to hold a useful value[.](#4.sentence-3)
**Effect on original feature:** Deletion of semantically well-defined feature[.](#4.sentence-4)
**Difficulty of converting:** Semantic transformation[.](#4.sentence-5)
**How widely used:** Seldom[.](#4.sentence-6)
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L3256)
**Affected subclause:** [[dcl.spec.auto]](dcl.spec.auto)
**Change:** The keyword auto cannot be used as a storage class specifier[.](#5.sentence-1)
[*Example [4](#example-4)*: void f() {auto int x; // valid C, invalid C++} — *end example*]
**Rationale:** Allowing the use of auto to deduce the type
of a variable from its initializer results in undesired interpretations ofauto as a storage class specifier in certain contexts[.](#5.sentence-2)
**Effect on original feature:** Deletion of semantically well-defined feature[.](#5.sentence-3)
**Difficulty of converting:** Syntactic transformation[.](#5.sentence-4)
**How widely used:** Rare[.](#5.sentence-5)
[6](#6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L3279)
**Affected subclause:** [[dcl.fct]](dcl.fct)
**Change:** In C++, a function declared with an empty parameter list takes no arguments[.](#6.sentence-1)
In C, an empty parameter list means that the number and type of the function arguments are unknown[.](#6.sentence-2)
[*Example [5](#example-5)*: int f(); // means int f(void) in C++// int f( unknown ) in C — *end example*]
**Rationale:** This is to avoid function calls
with the wrong number or type of arguments[.](#6.sentence-3)
**Effect on original feature:** Change to semantics of well-defined feature[.](#6.sentence-4)
This feature was marked as “obsolescent” in C[.](#6.sentence-5)
**Difficulty of converting:** Syntactic transformation[.](#6.sentence-6)
The function declarations using C incomplete declaration style must
be completed to become full prototype declarations[.](#6.sentence-7)
A program may need to be updated further if different calls to the
same (non-prototype) function have different numbers of arguments or
if the type of corresponding arguments differed[.](#6.sentence-8)
**How widely used:** Common[.](#6.sentence-9)
[7](#7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L3307)
**Affected subclause:** [[dcl.fct]](dcl.fct) [see [[expr.sizeof]](expr.sizeof "7.6.2.5Sizeof")]
**Change:** In C++, types may not be defined in return or parameter types[.](#7.sentence-2)
In C, these type definitions are allowed[.](#7.sentence-3)
[*Example [6](#example-6)*: void f( struct S { int a; } arg ) {} // valid C, invalid C++enum E { A, B, C } f() {} // valid C, invalid C++ — *end example*]
**Rationale:** When comparing types in different translation units, C++ relies
on name equivalence when C relies on structural equivalence[.](#7.sentence-4)
Regarding parameter types: since the type defined in a parameter list
would be in the scope of the function, the only legal calls in C++
would be from within the function itself[.](#7.sentence-5)
**Effect on original feature:** Deletion of semantically well-defined feature[.](#7.sentence-6)
**Difficulty of converting:** Semantic transformation[.](#7.sentence-7)
The type definitions must be moved to file scope, or in header files[.](#7.sentence-8)
**How widely used:** Seldom[.](#7.sentence-9)
This style of type definition is seen as poor coding style[.](#7.sentence-10)
[8](#8)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L3334)
**Affected subclause:** [[dcl.fct.def]](dcl.fct.def)
**Change:** In C++, the syntax for function definition excludes the “old-style” C function[.](#8.sentence-1)
In C, “old-style” syntax is allowed, but deprecated as “obsolescent”[.](#8.sentence-2)
**Rationale:** Prototypes are essential to type safety[.](#8.sentence-3)
**Effect on original feature:** Deletion of semantically well-defined feature[.](#8.sentence-4)
**Difficulty of converting:** Syntactic transformation[.](#8.sentence-5)
**How widely used:** Common in old programs, but already known to be obsolescent[.](#8.sentence-6)
[9](#9)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L3347)
**Affected subclause:** [[dcl.init.aggr]](dcl.init.aggr)
**Change:** In C++, designated initialization support is restricted
compared to the corresponding functionality in C[.](#9.sentence-1)
In C++,
designators for non-static data members
must be specified in declaration order,
designators for array elements and nested designators
are not supported,
and
designated and non-designated initializers
cannot be mixed in the same initializer list[.](#9.sentence-2)
[*Example [7](#example-7)*: struct A { int x, y; };struct B { struct A a; };struct A a = {.y = 1, .x = 2}; // valid C, invalid C++int arr[3] = {[1] = 5}; // valid C, invalid C++struct B b = {.a.x = 0}; // valid C, invalid C++struct A c = {.x = 1, 2}; // valid C, invalid C++ — *end example*]
**Rationale:** In C++, members are destroyed in reverse construction order
and the elements of an initializer list are evaluated in lexical order,
so member initializers must be specified in order[.](#9.sentence-3)
Array designators conflict with [*lambda-expression*](expr.prim.lambda.general#nt:lambda-expression "7.5.6.1General[expr.prim.lambda.general]") syntax[.](#9.sentence-4)
Nested designators are seldom used[.](#9.sentence-5)
**Effect on original feature:** Deletion of feature that is incompatible with C++[.](#9.sentence-6)
**Difficulty of converting:** Syntactic transformation[.](#9.sentence-7)
**How widely used:** Out-of-order initializers are common[.](#9.sentence-8)
The other features are seldom used[.](#9.sentence-9)
[10](#10)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L3384)
**Affected subclause:** [[dcl.init.string]](dcl.init.string)
**Change:** In C++, when initializing an array of character with a string, the number of
characters in the string (including the terminating '\0') must not exceed the
number of elements in the array[.](#10.sentence-1)
In C, an array can be initialized with a string even if
the array is not large enough to contain the string-terminating '\0'[.](#10.sentence-2)
[*Example [8](#example-8)*: char array[4] = "abcd"; // valid C, invalid C++ — *end example*]
**Rationale:** When these non-terminated arrays are manipulated by standard
string functions, there is potential for major catastrophe[.](#10.sentence-3)
**Effect on original feature:** Deletion of semantically well-defined feature[.](#10.sentence-4)
**Difficulty of converting:** Semantic transformation[.](#10.sentence-5)
The arrays must be declared one element bigger to contain the
string terminating '\0'[.](#10.sentence-6)
**How widely used:** Seldom[.](#10.sentence-7)
This style of array initialization is seen as poor coding style[.](#10.sentence-8)
[11](#11)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L3409)
**Affected subclause:** [[dcl.enum]](dcl.enum)
**Change:** C++ objects of enumeration type can only be assigned values of the same enumeration type[.](#11.sentence-1)
In C, objects of enumeration type can be assigned values of any integral type[.](#11.sentence-2)
[*Example [9](#example-9)*: enum color { red, blue, green };enum color c = 1; // valid C, invalid C++ — *end example*]
**Rationale:** The type-safe nature of C++[.](#11.sentence-3)
**Effect on original feature:** Deletion of semantically well-defined feature[.](#11.sentence-4)
**Difficulty of converting:** Syntactic transformation[.](#11.sentence-5)
(The type error produced by the assignment can be automatically
corrected by applying an explicit cast[.](#11.sentence-6))
**How widely used:** Common[.](#11.sentence-7)
[12](#12)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L3432)
**Affected subclause:** [[dcl.enum]](dcl.enum)
**Change:** In C++, the type of an enumerator is its enumeration[.](#12.sentence-1)
In C, the type of an enumerator is int[.](#12.sentence-2)
[*Example [10](#example-10)*: enum e { A };sizeof(A) == sizeof(int) // in Csizeof(A) == sizeof(e) // in C++/* and sizeof(int) is not necessarily equal to sizeof(e) */ — *end example*]
**Rationale:** In C++, an enumeration is a distinct type[.](#12.sentence-3)
**Effect on original feature:** Change to semantics of well-defined feature[.](#12.sentence-4)
**Difficulty of converting:** Semantic transformation[.](#12.sentence-5)
**How widely used:** Seldom[.](#12.sentence-6)
The only time this affects existing C code is when the size of an
enumerator is taken[.](#12.sentence-7)
Taking the size of an enumerator is not a
common C coding practice[.](#12.sentence-8)
[13](#13)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L3458)
**Affected subclause:** [[dcl.align]](dcl.align)
**Change:** In C++,
an [*alignment-specifier*](dcl.attr.grammar#nt:alignment-specifier "9.13.1Attribute syntax and semantics[dcl.attr.grammar]") is an [*attribute-specifier*](dcl.attr.grammar#nt:attribute-specifier "9.13.1Attribute syntax and semantics[dcl.attr.grammar]")[.](#13.sentence-1)
In C, an [*alignment-specifier*](dcl.attr.grammar#nt:alignment-specifier "9.13.1Attribute syntax and semantics[dcl.attr.grammar]") is a *declaration-specifier*[.](#13.sentence-2)
[*Example [11](#example-11)*: #include <stdalign.h>unsigned alignas(8) int x; // valid C, invalid C++unsigned int y alignas(8); // valid C++, invalid C — *end example*]
**Rationale:** C++ requires unambiguous placement of the [*alignment-specifier*](dcl.attr.grammar#nt:alignment-specifier "9.13.1Attribute syntax and semantics[dcl.attr.grammar]")[.](#13.sentence-3)
**Effect on original feature:** Deletion of semantically well-defined feature[.](#13.sentence-4)
**Difficulty of converting:** Syntactic transformation[.](#13.sentence-5)
**How widely used:** Seldom[.](#13.sentence-6)

234
cppdraft/diff/expr.md Normal file
View File

@@ -0,0 +1,234 @@
[diff.expr]
# Annex C (informative) Compatibility [[diff]](./#diff)
## C.7 C++ and C [[diff.iso]](diff.iso#diff.expr)
### C.7.4 [[expr]](expr "7Expressions"): expressions [diff.expr]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L2966)
**Affected subclause:** [[conv.ptr]](conv.ptr)
**Change:** Converting void* to a pointer-to-object type requires casting[.](#1.sentence-1)
[*Example [1](#example-1)*: char a[10];void* b=a;void foo() {char* c=b;}
C accepts this usage of pointer to void being assigned
to a pointer to object type[.](#1.sentence-2)
C++ does not[.](#1.sentence-3)
— *end example*]
**Rationale:** C++ tries harder than C to enforce compile-time type safety[.](#1.sentence-4)
**Effect on original feature:** Deletion of semantically well-defined feature[.](#1.sentence-5)
**Difficulty of converting:** Can be automated[.](#1.sentence-6)
Violations will be diagnosed by the C++ translator[.](#1.sentence-7)
The fix is to add a cast[.](#1.sentence-8)
[*Example [2](#example-2)*: char* c = (char*) b; — *end example*]
**How widely used:** This is fairly widely used but it is good
programming practice to add the cast when assigning pointer-to-void to pointer-to-object[.](#1.sentence-9)
Some C translators will give a warning
if the cast is not used[.](#1.sentence-10)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L3002)
**Affected subclause:** [[expr.arith.conv]](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 not valid[.](#2.sentence-1)
[*Example [3](#example-3)*: enum E1 { e };enum E2 { f };int b = e <= 3.7; // valid in C; ill-formed in C++int k = f - e; // valid in C; ill-formed in C++int x = 1 ? e : f; // valid in C; ill-formed in C++ — *end example*]
**Rationale:** Reinforcing type safety in C++[.](#2.sentence-2)
**Effect on original feature:** Well-formed C code will not compile with this International Standard[.](#2.sentence-3)
**Difficulty of converting:** Violations will be diagnosed by the C++ translator[.](#2.sentence-4)
The original behavior can be restored with a cast or integral promotion[.](#2.sentence-5)
[*Example [4](#example-4)*: enum E1 { e };enum E2 { f };int b = (int)e <= 3.7;int k = +f - e; — *end example*]
**How widely used:** Uncommon[.](#2.sentence-6)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L3033)
**Affected subclauses:** [[expr.post.incr]](expr.post.incr) and [[expr.pre.incr]](expr.pre.incr)
**Change:** Decrement operator is not allowed with bool operand[.](#3.sentence-1)
**Rationale:** Feature with surprising semantics[.](#3.sentence-2)
**Effect on original feature:** A valid C expression utilizing the decrement operator on
a bool lvalue
(for instance, via the C typedef in [<stdbool.h>](stdbool.h.syn#header:%3cstdbool.h%3e "17.15.5Header <stdbool.h> synopsis[stdbool.h.syn]"))
is ill-formed in C++[.](#3.sentence-3)
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L3044)
**Affected subclauses:** [[expr.sizeof]](expr.sizeof) and [[expr.cast]](expr.cast)
**Change:** In C++, types can only be defined in declarations, not in expressions[.](#4.sentence-1)
In C, a sizeof expression or cast expression may define a new type[.](#4.sentence-2)
[*Example [5](#example-5)*:
p = (void*)(struct x {int i;} *)0; defines a new type, struct x[.](#4.sentence-3)
— *end example*]
**Rationale:** This prohibition helps to clarify the location of
definitions in the source code[.](#4.sentence-4)
**Effect on original feature:** Deletion of semantically well-defined feature[.](#4.sentence-5)
**Difficulty of converting:** Syntactic transformation[.](#4.sentence-6)
**How widely used:** Seldom[.](#4.sentence-7)
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L3064)
**Affected subclauses:** [[expr.rel]](expr.rel) and [[expr.eq]](expr.eq)
**Change:** C allows directly comparing two objects of array type; C++ does not[.](#5.sentence-1)
**Rationale:** The behavior is confusing because it compares not the contents of the two
arrays, but their addresses[.](#5.sentence-2)
**Effect on original feature:** Deletion of semantically well-defined feature that had unspecified behavior
in common use cases[.](#5.sentence-3)
**Difficulty of converting:** Violations will be diagnosed by the C++ translator[.](#5.sentence-4)
The original behavior
can be replicated by explicitly casting either array to a pointer, such as by
using a unary +[.](#5.sentence-5)
[*Example [6](#example-6)*: int arr1[5];int arr2[5];int same = arr1 == arr2; // valid C, ill-formed C++int idem = arr1 == +arr2; // valid in both C and C++ — *end example*]
**How widely used:** Rare[.](#5.sentence-6)
[6](#6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L3088)
**Affected subclauses:** [[expr.cond]](expr.cond), [[expr.assign]](expr.assign), and [[expr.comma]](expr.comma)
**Change:** The result of a conditional expression, an assignment expression, or a comma expression may be an lvalue[.](#6.sentence-1)
**Rationale:** C++ is an object-oriented language, placing relatively
more emphasis on lvalues[.](#6.sentence-2)
For example, function calls may
yield lvalues[.](#6.sentence-3)
**Effect on original feature:** Change to semantics of well-defined feature[.](#6.sentence-4)
Some C
expressions that implicitly rely on lvalue-to-rvalue
conversions will yield different results[.](#6.sentence-5)
[*Example [7](#example-7)*:
char arr[100];sizeof(0, arr) yields100 in C++ andsizeof(char*) in C[.](#6.sentence-6)
— *end example*]
**Difficulty of converting:** Programs must add explicit casts to the appropriate rvalue[.](#6.sentence-7)
**How widely used:** Rare[.](#6.sentence-8)

View File

@@ -0,0 +1,18 @@
[diff.header.iso646.h]
# Annex C (informative) Compatibility [[diff]](./#diff)
## C.8 C standard library [[diff.library]](diff.library#diff.header.iso646.h)
### C.8.3 Modifications to definitions [[diff.mods.to.definitions]](diff.mods.to.definitions#diff.header.iso646.h)
#### C.8.3.3 Header <iso646.h> [diff.header.iso646.h]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L3733)
The tokensand,and_eq,bitand,bitor,compl,not,not_eq,or,or_eq,xor,
andxor_eq are keywords in C++ ([[lex.key]](lex.key "5.12Keywords")),
and are not introduced as macros
by [<iso646.h>](iso646.h.syn#header:%3ciso646.h%3e "17.15.3Header <iso646.h> synopsis[iso646.h.syn]")[.](#1.sentence-1)

1464
cppdraft/diff/iso.md Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,15 @@
[diff.iso.general]
# Annex C (informative) Compatibility [[diff]](./#diff)
## C.7 C++ and C [[diff.iso]](diff.iso#general)
### C.7.1 General [diff.iso.general]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L2738)
Subclause [[diff.iso]](diff.iso "C.7C++ and C") lists the differences between C++ and C,
in addition to those listed above,
by the chapters of this document[.](#1.sentence-1)

177
cppdraft/diff/lex.md Normal file
View File

@@ -0,0 +1,177 @@
[diff.lex]
# Annex C (informative) Compatibility [[diff]](./#diff)
## C.7 C++ and C [[diff.iso]](diff.iso#diff.lex)
### C.7.2 [[lex]](lex "5Lexical conventions"): lexical conventions [diff.lex]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L2746)
**Affected subclause:** [[lex.key]](lex.key)
**Change:** New Keywords[.](#1.sentence-1)
New keywords are added to C++;
see [[lex.key]](lex.key "5.12Keywords")[.](#1.sentence-2)
**Rationale:** These keywords were added in order to implement the new
semantics of C++[.](#1.sentence-3)
**Effect on original feature:** Change to semantics of well-defined feature[.](#1.sentence-4)
Any C programs that used any of these keywords as identifiers
are not valid C++ programs[.](#1.sentence-5)
**Difficulty of converting:** Syntactic transformation[.](#1.sentence-6)
Converting one specific program is easy[.](#1.sentence-7)
Converting a large collection
of related programs takes more work[.](#1.sentence-8)
**How widely used:** Common[.](#1.sentence-9)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L2766)
**Affected subclause:** [[lex.ccon]](lex.ccon)
**Change:** Type of [*character-literal*](lex.ccon#nt:character-literal "5.13.3Character literals[lex.ccon]") is changed from int to char[.](#2.sentence-1)
**Rationale:** This is needed for improved overloaded function argument type
matching[.](#2.sentence-2)
[*Example [1](#example-1)*: int function( int i );int function( char c );
function( 'x' );
It is preferable that this call match the second version of
function rather than the first[.](#2.sentence-3)
— *end example*]
**Effect on original feature:** Change to semantics of well-defined feature[.](#2.sentence-4)
C programs which depend onsizeof('x') == sizeof(int) will not work the same as C++ programs[.](#2.sentence-5)
**Difficulty of converting:** Simple[.](#2.sentence-6)
**How widely used:** Programs which depend upon sizeof('x') are probably rare[.](#2.sentence-7)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L2794)
**Affected subclause:** [[lex.string]](lex.string)
**Change:** Concatenated [*string-literal*](lex.string#nt:string-literal "5.13.5String literals[lex.string]")*s* can no longer have
conflicting [*encoding-prefix*](lex.ccon#nt:encoding-prefix "5.13.3Character literals[lex.ccon]")es[.](#3.sentence-1)
**Rationale:** Removal of non-portable feature[.](#3.sentence-2)
**Effect on original feature:** Concatenation of [*string-literal*](lex.string#nt:string-literal "5.13.5String literals[lex.string]")*s* with different [*encoding-prefix*](lex.ccon#nt:encoding-prefix "5.13.3Character literals[lex.ccon]")es
is now ill-formed[.](#3.sentence-3)
**Difficulty of converting:** Syntactic transformation[.](#3.sentence-4)
**How widely used:** Seldom[.](#3.sentence-5)
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L2809)
**Affected subclause:** [[lex.string]](lex.string)
**Change:** String literals made const[.](#4.sentence-1)
The type of a [*string-literal*](lex.string#nt:string-literal "5.13.5String literals[lex.string]") is changed
from “array of char”
to “array of const char”[.](#4.sentence-2)
The type of a UTF-8 string literal is changed
from “array of char”
to “array of const char8_t”[.](#4.sentence-3)
The type of a UTF-16 string literal is changed
from “array of *some-integer-type*”
to “array of const char16_t”[.](#4.sentence-4)
The type of a UTF-32 string literal is changed
from “array of *some-integer-type*”
to “array of const char32_t”[.](#4.sentence-5)
The type of a wide string literal is changed
from “array of wchar_t”
to “array of const wchar_t”[.](#4.sentence-6)
**Rationale:** This avoids calling an inappropriate overloaded function,
which might expect to be able to modify its argument[.](#4.sentence-7)
**Effect on original feature:** Change to semantics of well-defined feature[.](#4.sentence-8)
**Difficulty of converting:** Syntactic transformation[.](#4.sentence-9)
The fix is to add a cast:char* p = "abc"; // valid in C, invalid in C++void f(char*) {char* p = (char*)"abc"; // OK, cast added f(p);
f((char*)"def"); // OK, cast added}
**How widely used:** Programs that have a legitimate reason to treat string literal objects
as potentially modifiable memory are probably rare[.](#4.sentence-11)

220
cppdraft/diff/library.md Normal file
View File

@@ -0,0 +1,220 @@
[diff.library]
# Annex C (informative) Compatibility [[diff]](./#diff)
## C.8 C standard library [diff.library]
### [C.8.1](#general) General [[diff.library.general]](diff.library.general)
[1](#general-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L3683)
Subclause [diff.library] summarizes the explicit changes in headers,
definitions, declarations, or behavior between the C standard library
in the C standard and the parts of the C++ standard library that were
included from the C standard library[.](#general-1.sentence-1)
### [C.8.2](#diff.mods.to.headers) Modifications to headers [[diff.mods.to.headers]](diff.mods.to.headers)
[1](#diff.mods.to.headers-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L3691)
For compatibility with the C standard library,
the C++ standard library provides the C headers enumerated
in [[support.c.headers]](support.c.headers "17.15C headers")[.](#diff.mods.to.headers-1.sentence-1)
[2](#diff.mods.to.headers-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L3696)
There are no C++ headers for the C standard library's headers<stdnoreturn.h> and <threads.h>,
nor are these headers from the C standard library headers themselves part of C++[.](#diff.mods.to.headers-2.sentence-1)
[3](#diff.mods.to.headers-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L3701)
The C headers [<complex.h>](complex.h.syn#header:%3ccomplex.h%3e "17.15.2Header <complex.h> synopsis[complex.h.syn]") and[<tgmath.h>](tgmath.h.syn#header:%3ctgmath.h%3e "17.15.6Header <tgmath.h> synopsis[tgmath.h.syn]") do not contain any of the content from
the C standard library and instead merely include other headers from the C++
standard library[.](#diff.mods.to.headers-3.sentence-1)
### [C.8.3](#diff.mods.to.definitions) Modifications to definitions [[diff.mods.to.definitions]](diff.mods.to.definitions)
#### [C.8.3.1](#diff.char16) Types char8_t, char16_t, and char32_t [[diff.char16]](diff.char16)
[1](#diff.char16-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L3711)
The types char8_t, char16_t, and char32_t are distinct types rather than typedefs to existing integral types[.](#diff.char16-1.sentence-1)
The tokens char8_t, char16_t, and char32_t are keywords in C++ ([[lex.key]](lex.key "5.12Keywords"))[.](#diff.char16-1.sentence-2)
They do not appear as macro or type names defined in[<cuchar>](cuchar.syn#header:%3ccuchar%3e "28.7.4Header <cuchar> synopsis[cuchar.syn]")[.](#diff.char16-1.sentence-3)
#### [C.8.3.2](#diff.wchar.t) Type wchar_t [[diff.wchar.t]](diff.wchar.t)
[1](#diff.wchar.t-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L3721)
The type wchar_t is a distinct type rather than a typedef to an
existing integral type[.](#diff.wchar.t-1.sentence-1)
The token wchar_t is a keyword in C++ ([[lex.key]](lex.key "5.12Keywords"))[.](#diff.wchar.t-1.sentence-2)
It does not appear as a macro or type name defined in any of[<cstddef>](cstddef.syn#header:%3ccstddef%3e "17.2.1Header <cstddef> synopsis[cstddef.syn]"),[<cstdlib>](cstdlib.syn#header:%3ccstdlib%3e "17.2.2Header <cstdlib> synopsis[cstdlib.syn]"),
or [<cwchar>](cwchar.syn#header:%3ccwchar%3e "28.7.3Header <cwchar> synopsis[cwchar.syn]")[.](#diff.wchar.t-1.sentence-3)
#### [C.8.3.3](#diff.header.iso646.h) Header <iso646.h> [[diff.header.iso646.h]](diff.header.iso646.h)
[1](#diff.header.iso646.h-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L3733)
The tokensand,and_eq,bitand,bitor,compl,not,not_eq,or,or_eq,xor,
andxor_eq are keywords in C++ ([[lex.key]](lex.key "5.12Keywords")),
and are not introduced as macros
by [<iso646.h>](iso646.h.syn#header:%3ciso646.h%3e "17.15.3Header <iso646.h> synopsis[iso646.h.syn]")[.](#diff.header.iso646.h-1.sentence-1)
#### [C.8.3.4](#diff.null) Macro NULL [[diff.null]](diff.null)
[1](#diff.null-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L3753)
The macroNULL,
defined in any of[<clocale>](clocale.syn#header:%3cclocale%3e "28.3.5.1Header <clocale> synopsis[clocale.syn]"),[<cstddef>](cstddef.syn#header:%3ccstddef%3e "17.2.1Header <cstddef> synopsis[cstddef.syn]"),[<cstdio>](cstdio.syn#header:%3ccstdio%3e "31.13.1Header <cstdio> synopsis[cstdio.syn]"),[<cstdlib>](cstdlib.syn#header:%3ccstdlib%3e "17.2.2Header <cstdlib> synopsis[cstdlib.syn]"),[<cstring>](cstring.syn#header:%3ccstring%3e "27.5.1Header <cstring> synopsis[cstring.syn]"),[<ctime>](ctime.syn#header:%3cctime%3e "30.15Header <ctime> synopsis[ctime.syn]"),
or [<cwchar>](cwchar.syn#header:%3ccwchar%3e "28.7.3Header <cwchar> synopsis[cwchar.syn]"),
is an implementation-defined null pointer constant in
C++ ([[support.types]](support.types "17.2Common definitions"))[.](#diff.null-1.sentence-1)
### [C.8.4](#diff.mods.to.declarations) Modifications to declarations [[diff.mods.to.declarations]](diff.mods.to.declarations)
[1](#diff.mods.to.declarations-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L3769)
Header [<cstring>](cstring.syn#header:%3ccstring%3e "27.5.1Header <cstring> synopsis[cstring.syn]"):
The following functions have different declarations:
- [(1.1)](#diff.mods.to.declarations-1.1)
strchr
- [(1.2)](#diff.mods.to.declarations-1.2)
strpbrk
- [(1.3)](#diff.mods.to.declarations-1.3)
strrchr
- [(1.4)](#diff.mods.to.declarations-1.4)
strstr
- [(1.5)](#diff.mods.to.declarations-1.5)
memchr
Subclause [[cstring.syn]](cstring.syn "27.5.1Header <cstring> synopsis") describes the changes[.](#diff.mods.to.declarations-1.sentence-2)
[2](#diff.mods.to.declarations-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L3782)
Header [<cwchar>](cwchar.syn#header:%3ccwchar%3e "28.7.3Header <cwchar> synopsis[cwchar.syn]"):
The following functions have different declarations:
- [(2.1)](#diff.mods.to.declarations-2.1)
wcschr
- [(2.2)](#diff.mods.to.declarations-2.2)
wcspbrk
- [(2.3)](#diff.mods.to.declarations-2.3)
wcsrchr
- [(2.4)](#diff.mods.to.declarations-2.4)
wcsstr
- [(2.5)](#diff.mods.to.declarations-2.5)
wmemchr
Subclause [[cwchar.syn]](cwchar.syn "28.7.3Header <cwchar> synopsis") describes the changes[.](#diff.mods.to.declarations-2.sentence-2)
[3](#diff.mods.to.declarations-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L3795)
Header [<cstddef>](cstddef.syn#header:%3ccstddef%3e "17.2.1Header <cstddef> synopsis[cstddef.syn]") declares the names nullptr_t, byte, and to_integer,
and the operators and operator templates in [[support.types.byteops]](support.types.byteops "17.2.5byte type operations"),
in addition to the names declared in[<stddef.h>](support.c.headers.general#header:%3cstddef.h%3e "17.15.1General[support.c.headers.general]") in the C standard library[.](#diff.mods.to.declarations-3.sentence-1)
### [C.8.5](#diff.mods.to.behavior) Modifications to behavior [[diff.mods.to.behavior]](diff.mods.to.behavior)
#### [C.8.5.1](#diff.mods.to.behavior.general) General [[diff.mods.to.behavior.general]](diff.mods.to.behavior.general)
[1](#diff.mods.to.behavior.general-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L3806)
Header [<cstdlib>](cstdlib.syn#header:%3ccstdlib%3e "17.2.2Header <cstdlib> synopsis[cstdlib.syn]"):
The following functions have different behavior:
- [(1.1)](#diff.mods.to.behavior.general-1.1)
atexit
- [(1.2)](#diff.mods.to.behavior.general-1.2)
exit
- [(1.3)](#diff.mods.to.behavior.general-1.3)
abort
Subclause [[support.start.term]](support.start.term "17.5Startup and termination") describes the changes[.](#diff.mods.to.behavior.general-1.sentence-2)
[2](#diff.mods.to.behavior.general-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L3817)
Header [<csetjmp>](csetjmp.syn#header:%3ccsetjmp%3e "17.14.3Header <csetjmp> synopsis[csetjmp.syn]"):
The following functions have different behavior:
- [(2.1)](#diff.mods.to.behavior.general-2.1)
longjmp
Subclause [[csetjmp.syn]](csetjmp.syn "17.14.3Header <csetjmp> synopsis") describes the changes[.](#diff.mods.to.behavior.general-2.sentence-2)
#### [C.8.5.2](#diff.offsetof) Macro offsetof(*type*, *member-designator*) [[diff.offsetof]](diff.offsetof)
[1](#diff.offsetof-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L3829)
The macro offsetof, defined in[<cstddef>](cstddef.syn#header:%3ccstddef%3e "17.2.1Header <cstddef> synopsis[cstddef.syn]"),
accepts a restricted set of *type* arguments in C++[.](#diff.offsetof-1.sentence-1)
Subclause [[support.types.layout]](support.types.layout "17.2.4Sizes, alignments, and offsets") describes the change[.](#diff.offsetof-1.sentence-2)
#### [C.8.5.3](#diff.malloc) Memory allocation functions [[diff.malloc]](diff.malloc)
[1](#diff.malloc-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L3837)
The functionsaligned_alloc,calloc,malloc,
andrealloc are restricted in C++[.](#diff.malloc-1.sentence-1)
Subclause [[c.malloc]](c.malloc "20.2.12C library memory allocation") describes the changes[.](#diff.malloc-1.sentence-2)

View File

@@ -0,0 +1,16 @@
[diff.library.general]
# Annex C (informative) Compatibility [[diff]](./#diff)
## C.8 C standard library [[diff.library]](diff.library#general)
### C.8.1 General [diff.library.general]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L3683)
Subclause [[diff.library]](diff.library "C.8C standard library") summarizes the explicit changes in headers,
definitions, declarations, or behavior between the C standard library
in the C standard and the parts of the C++ standard library that were
included from the C standard library[.](#1.sentence-1)

18
cppdraft/diff/malloc.md Normal file
View File

@@ -0,0 +1,18 @@
[diff.malloc]
# Annex C (informative) Compatibility [[diff]](./#diff)
## C.8 C standard library [[diff.library]](diff.library#diff.malloc)
### C.8.5 Modifications to behavior [[diff.mods.to.behavior]](diff.mods.to.behavior#diff.malloc)
#### C.8.5.3 Memory allocation functions [diff.malloc]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L3837)
The functionsaligned_alloc,calloc,malloc,
andrealloc are restricted in C++[.](#1.sentence-1)
Subclause [[c.malloc]](c.malloc "20.2.12C library memory allocation") describes the changes[.](#1.sentence-2)

View File

@@ -0,0 +1,65 @@
[diff.mods.to.behavior]
# Annex C (informative) Compatibility [[diff]](./#diff)
## C.8 C standard library [[diff.library]](diff.library#diff.mods.to.behavior)
### C.8.5 Modifications to behavior [diff.mods.to.behavior]
#### [C.8.5.1](#general) General [[diff.mods.to.behavior.general]](diff.mods.to.behavior.general)
[1](#general-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L3806)
Header [<cstdlib>](cstdlib.syn#header:%3ccstdlib%3e "17.2.2Header <cstdlib> synopsis[cstdlib.syn]"):
The following functions have different behavior:
- [(1.1)](#general-1.1)
atexit
- [(1.2)](#general-1.2)
exit
- [(1.3)](#general-1.3)
abort
Subclause [[support.start.term]](support.start.term "17.5Startup and termination") describes the changes[.](#general-1.sentence-2)
[2](#general-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L3817)
Header [<csetjmp>](csetjmp.syn#header:%3ccsetjmp%3e "17.14.3Header <csetjmp> synopsis[csetjmp.syn]"):
The following functions have different behavior:
- [(2.1)](#general-2.1)
longjmp
Subclause [[csetjmp.syn]](csetjmp.syn "17.14.3Header <csetjmp> synopsis") describes the changes[.](#general-2.sentence-2)
#### [C.8.5.2](#diff.offsetof) Macro offsetof(*type*, *member-designator*) [[diff.offsetof]](diff.offsetof)
[1](#diff.offsetof-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L3829)
The macro offsetof, defined in[<cstddef>](cstddef.syn#header:%3ccstddef%3e "17.2.1Header <cstddef> synopsis[cstddef.syn]"),
accepts a restricted set of *type* arguments in C++[.](#diff.offsetof-1.sentence-1)
Subclause [[support.types.layout]](support.types.layout "17.2.4Sizes, alignments, and offsets") describes the change[.](#diff.offsetof-1.sentence-2)
#### [C.8.5.3](#diff.malloc) Memory allocation functions [[diff.malloc]](diff.malloc)
[1](#diff.malloc-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L3837)
The functionsaligned_alloc,calloc,malloc,
andrealloc are restricted in C++[.](#diff.malloc-1.sentence-1)
Subclause [[c.malloc]](c.malloc "20.2.12C library memory allocation") describes the changes[.](#diff.malloc-1.sentence-2)

View File

@@ -0,0 +1,43 @@
[diff.mods.to.behavior.general]
# Annex C (informative) Compatibility [[diff]](./#diff)
## C.8 C standard library [[diff.library]](diff.library#diff.mods.to.behavior.general)
### C.8.5 Modifications to behavior [[diff.mods.to.behavior]](diff.mods.to.behavior#general)
#### C.8.5.1 General [diff.mods.to.behavior.general]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L3806)
Header [<cstdlib>](cstdlib.syn#header:%3ccstdlib%3e "17.2.2Header <cstdlib> synopsis[cstdlib.syn]"):
The following functions have different behavior:
- [(1.1)](#1.1)
atexit
- [(1.2)](#1.2)
exit
- [(1.3)](#1.3)
abort
Subclause [[support.start.term]](support.start.term "17.5Startup and termination") describes the changes[.](#1.sentence-2)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L3817)
Header [<csetjmp>](csetjmp.syn#header:%3ccsetjmp%3e "17.14.3Header <csetjmp> synopsis[csetjmp.syn]"):
The following functions have different behavior:
- [(2.1)](#2.1)
longjmp
Subclause [[csetjmp.syn]](csetjmp.syn "17.14.3Header <csetjmp> synopsis") describes the changes[.](#2.sentence-2)

View File

@@ -0,0 +1,73 @@
[diff.mods.to.declarations]
# Annex C (informative) Compatibility [[diff]](./#diff)
## C.8 C standard library [[diff.library]](diff.library#diff.mods.to.declarations)
### C.8.4 Modifications to declarations [diff.mods.to.declarations]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L3769)
Header [<cstring>](cstring.syn#header:%3ccstring%3e "27.5.1Header <cstring> synopsis[cstring.syn]"):
The following functions have different declarations:
- [(1.1)](#1.1)
strchr
- [(1.2)](#1.2)
strpbrk
- [(1.3)](#1.3)
strrchr
- [(1.4)](#1.4)
strstr
- [(1.5)](#1.5)
memchr
Subclause [[cstring.syn]](cstring.syn "27.5.1Header <cstring> synopsis") describes the changes[.](#1.sentence-2)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L3782)
Header [<cwchar>](cwchar.syn#header:%3ccwchar%3e "28.7.3Header <cwchar> synopsis[cwchar.syn]"):
The following functions have different declarations:
- [(2.1)](#2.1)
wcschr
- [(2.2)](#2.2)
wcspbrk
- [(2.3)](#2.3)
wcsrchr
- [(2.4)](#2.4)
wcsstr
- [(2.5)](#2.5)
wmemchr
Subclause [[cwchar.syn]](cwchar.syn "28.7.3Header <cwchar> synopsis") describes the changes[.](#2.sentence-2)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L3795)
Header [<cstddef>](cstddef.syn#header:%3ccstddef%3e "17.2.1Header <cstddef> synopsis[cstddef.syn]") declares the names nullptr_t, byte, and to_integer,
and the operators and operator templates in [[support.types.byteops]](support.types.byteops "17.2.5byte type operations"),
in addition to the names declared in[<stddef.h>](support.c.headers.general#header:%3cstddef.h%3e "17.15.1General[support.c.headers.general]") in the C standard library[.](#3.sentence-1)

View File

@@ -0,0 +1,56 @@
[diff.mods.to.definitions]
# Annex C (informative) Compatibility [[diff]](./#diff)
## C.8 C standard library [[diff.library]](diff.library#diff.mods.to.definitions)
### C.8.3 Modifications to definitions [diff.mods.to.definitions]
#### [C.8.3.1](#diff.char16) Types char8_t, char16_t, and char32_t [[diff.char16]](diff.char16)
[1](#diff.char16-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L3711)
The types char8_t, char16_t, and char32_t are distinct types rather than typedefs to existing integral types[.](#diff.char16-1.sentence-1)
The tokens char8_t, char16_t, and char32_t are keywords in C++ ([[lex.key]](lex.key "5.12Keywords"))[.](#diff.char16-1.sentence-2)
They do not appear as macro or type names defined in[<cuchar>](cuchar.syn#header:%3ccuchar%3e "28.7.4Header <cuchar> synopsis[cuchar.syn]")[.](#diff.char16-1.sentence-3)
#### [C.8.3.2](#diff.wchar.t) Type wchar_t [[diff.wchar.t]](diff.wchar.t)
[1](#diff.wchar.t-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L3721)
The type wchar_t is a distinct type rather than a typedef to an
existing integral type[.](#diff.wchar.t-1.sentence-1)
The token wchar_t is a keyword in C++ ([[lex.key]](lex.key "5.12Keywords"))[.](#diff.wchar.t-1.sentence-2)
It does not appear as a macro or type name defined in any of[<cstddef>](cstddef.syn#header:%3ccstddef%3e "17.2.1Header <cstddef> synopsis[cstddef.syn]"),[<cstdlib>](cstdlib.syn#header:%3ccstdlib%3e "17.2.2Header <cstdlib> synopsis[cstdlib.syn]"),
or [<cwchar>](cwchar.syn#header:%3ccwchar%3e "28.7.3Header <cwchar> synopsis[cwchar.syn]")[.](#diff.wchar.t-1.sentence-3)
#### [C.8.3.3](#diff.header.iso646.h) Header <iso646.h> [[diff.header.iso646.h]](diff.header.iso646.h)
[1](#diff.header.iso646.h-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L3733)
The tokensand,and_eq,bitand,bitor,compl,not,not_eq,or,or_eq,xor,
andxor_eq are keywords in C++ ([[lex.key]](lex.key "5.12Keywords")),
and are not introduced as macros
by [<iso646.h>](iso646.h.syn#header:%3ciso646.h%3e "17.15.3Header <iso646.h> synopsis[iso646.h.syn]")[.](#diff.header.iso646.h-1.sentence-1)
#### [C.8.3.4](#diff.null) Macro NULL [[diff.null]](diff.null)
[1](#diff.null-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L3753)
The macroNULL,
defined in any of[<clocale>](clocale.syn#header:%3cclocale%3e "28.3.5.1Header <clocale> synopsis[clocale.syn]"),[<cstddef>](cstddef.syn#header:%3ccstddef%3e "17.2.1Header <cstddef> synopsis[cstddef.syn]"),[<cstdio>](cstdio.syn#header:%3ccstdio%3e "31.13.1Header <cstdio> synopsis[cstdio.syn]"),[<cstdlib>](cstdlib.syn#header:%3ccstdlib%3e "17.2.2Header <cstdlib> synopsis[cstdlib.syn]"),[<cstring>](cstring.syn#header:%3ccstring%3e "27.5.1Header <cstring> synopsis[cstring.syn]"),[<ctime>](ctime.syn#header:%3cctime%3e "30.15Header <ctime> synopsis[ctime.syn]"),
or [<cwchar>](cwchar.syn#header:%3ccwchar%3e "28.7.3Header <cwchar> synopsis[cwchar.syn]"),
is an implementation-defined null pointer constant in
C++ ([[support.types]](support.types "17.2Common definitions"))[.](#diff.null-1.sentence-1)

View File

@@ -0,0 +1,30 @@
[diff.mods.to.headers]
# Annex C (informative) Compatibility [[diff]](./#diff)
## C.8 C standard library [[diff.library]](diff.library#diff.mods.to.headers)
### C.8.2 Modifications to headers [diff.mods.to.headers]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L3691)
For compatibility with the C standard library,
the C++ standard library provides the C headers enumerated
in [[support.c.headers]](support.c.headers "17.15C headers")[.](#1.sentence-1)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L3696)
There are no C++ headers for the C standard library's headers<stdnoreturn.h> and <threads.h>,
nor are these headers from the C standard library headers themselves part of C++[.](#2.sentence-1)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L3701)
The C headers [<complex.h>](complex.h.syn#header:%3ccomplex.h%3e "17.15.2Header <complex.h> synopsis[complex.h.syn]") and[<tgmath.h>](tgmath.h.syn#header:%3ctgmath.h%3e "17.15.6Header <tgmath.h> synopsis[tgmath.h.syn]") do not contain any of the content from
the C standard library and instead merely include other headers from the C++
standard library[.](#3.sentence-1)

19
cppdraft/diff/null.md Normal file
View File

@@ -0,0 +1,19 @@
[diff.null]
# Annex C (informative) Compatibility [[diff]](./#diff)
## C.8 C standard library [[diff.library]](diff.library#diff.null)
### C.8.3 Modifications to definitions [[diff.mods.to.definitions]](diff.mods.to.definitions#diff.null)
#### C.8.3.4 Macro NULL [diff.null]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L3753)
The macroNULL,
defined in any of[<clocale>](clocale.syn#header:%3cclocale%3e "28.3.5.1Header <clocale> synopsis[clocale.syn]"),[<cstddef>](cstddef.syn#header:%3ccstddef%3e "17.2.1Header <cstddef> synopsis[cstddef.syn]"),[<cstdio>](cstdio.syn#header:%3ccstdio%3e "31.13.1Header <cstdio> synopsis[cstdio.syn]"),[<cstdlib>](cstdlib.syn#header:%3ccstdlib%3e "17.2.2Header <cstdlib> synopsis[cstdlib.syn]"),[<cstring>](cstring.syn#header:%3ccstring%3e "27.5.1Header <cstring> synopsis[cstring.syn]"),[<ctime>](ctime.syn#header:%3cctime%3e "30.15Header <ctime> synopsis[ctime.syn]"),
or [<cwchar>](cwchar.syn#header:%3ccwchar%3e "28.7.3Header <cwchar> synopsis[cwchar.syn]"),
is an implementation-defined null pointer constant in
C++ ([[support.types]](support.types "17.2Common definitions"))[.](#1.sentence-1)

18
cppdraft/diff/offsetof.md Normal file
View File

@@ -0,0 +1,18 @@
[diff.offsetof]
# Annex C (informative) Compatibility [[diff]](./#diff)
## C.8 C standard library [[diff.library]](diff.library#diff.offsetof)
### C.8.5 Modifications to behavior [[diff.mods.to.behavior]](diff.mods.to.behavior#diff.offsetof)
#### C.8.5.2 Macro offsetof(*type*, *member-designator*) [diff.offsetof]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L3829)
The macro offsetof, defined in[<cstddef>](cstddef.syn#header:%3ccstddef%3e "17.2.1Header <cstddef> synopsis[cstddef.syn]"),
accepts a restricted set of *type* arguments in C++[.](#1.sentence-1)
Subclause [[support.types.layout]](support.types.layout "17.2.4Sizes, alignments, and offsets") describes the change[.](#1.sentence-2)

Some files were not shown because too many files have changed in this diff Show More