Skip to content

Commit 04eb7aa

Browse files
authored
Merge 2018-06 LWG Motion 27
Fixes #2144
2 parents 73409aa + 16b35d6 commit 04eb7aa

File tree

11 files changed

+344
-1039
lines changed

11 files changed

+344
-1039
lines changed

source/compatibility.tex

Lines changed: 157 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1085,13 +1085,9 @@
10851085
and
10861086
\tcode{<unordered_set>}.
10871087
In addition the following C compatibility headers are new:
1088-
\tcode{<ccomplex>},
10891088
\tcode{<cfenv>},
10901089
\tcode{<cinttypes>},
1091-
\tcode{<cstdalign>},
1092-
\tcode{<cstdbool>},
10931090
\tcode{<cstdint>},
1094-
\tcode{<ctgmath>},
10951091
and
10961092
\tcode{<cuchar>}.
10971093
Valid \CppIII{} code that \tcode{\#include}{s} headers with these names may be
@@ -1123,40 +1119,6 @@
11231119
\rSec2[diff.cpp03.language.support]{\ref{language.support}:
11241120
language support library}
11251121

1126-
\diffref{new.delete.single}
1127-
\change Linking \tcode{new} and \tcode{delete} operators.
1128-
\rationale The two throwing single-object signatures of \tcode{operator new} and
1129-
\tcode{operator delete} are now specified to form the base functionality for
1130-
the other operators. This clarifies that replacing just these two signatures
1131-
changes others, even if they are not explicitly changed.
1132-
\effect
1133-
Valid \CppIII{} code that replaces global \tcode{new} or \tcode{delete}
1134-
operators may execute differently in this International Standard. For
1135-
example, the following program should write \tcode{"custom deallocation"} twice,
1136-
once for the single-object delete and once for the array delete.
1137-
1138-
\begin{codeblock}
1139-
#include <cstdio>
1140-
#include <cstdlib>
1141-
#include <new>
1142-
1143-
void* operator new(std::size_t size) throw(std::bad_alloc) {
1144-
return std::malloc(size);
1145-
}
1146-
1147-
void operator delete(void* ptr) throw() {
1148-
std::puts("custom deallocation");
1149-
std::free(ptr);
1150-
}
1151-
1152-
int main() {
1153-
int* i = new int;
1154-
delete i; // single-object delete
1155-
int* a = new int[3];
1156-
delete [] a; // array delete
1157-
}
1158-
\end{codeblock}
1159-
11601122
\diffref{new.delete.single}
11611123
\change \tcode{operator new} may throw exceptions other than
11621124
\tcode{std::bad_alloc}.
@@ -1165,6 +1127,10 @@
11651127
Valid \CppIII{} code that assumes that global \tcode{operator new} only
11661128
throws \tcode{std::bad_alloc} may execute differently in this International
11671129
Standard.
1130+
Valid \CppIII{} code that replaces the global replaceable \tcode{operator new}
1131+
is ill-formed in this International Standard,
1132+
because the exception specification of \tcode{throw(std::bad_alloc)}
1133+
was removed.
11681134

11691135
\rSec2[diff.cpp03.diagnostics]{\ref{diagnostics}: diagnostics library}
11701136

@@ -1186,7 +1152,7 @@
11861152
have different runtime behavior.
11871153

11881154
\diffref{refwrap}, \ref{arithmetic.operations}, \ref{comparisons},
1189-
\ref{logical.operations}, \ref{bitwise.operations}, \ref{depr.negators}
1155+
\ref{logical.operations}, \ref{bitwise.operations}
11901156
\change Standard function object types no longer derived from
11911157
\tcode{std::unary_function} or \tcode{std::binary_function}.
11921158
\rationale Superseded by new feature; \tcode{unary_function} and
@@ -1800,6 +1766,7 @@
18001766

18011767
\rSec2[diff.cpp14.depr]{\ref{depr}: compatibility features}
18021768

1769+
\nodiffref
18031770
\change
18041771
The class templates
18051772
\tcode{auto_ptr},
@@ -1818,6 +1785,7 @@
18181785
\effect Valid \CppXIV{} code that uses these class templates
18191786
and function templates may fail to compile in this International Standard.
18201787

1788+
\nodiffref
18211789
\change
18221790
Remove old iostreams members [depr.ios.members].
18231791
\rationale Redundant feature for compatibility with pre-standard code
@@ -1987,20 +1955,72 @@
19871955
}
19881956
\end{codeblock}
19891957

1958+
\rSec2[diff.cpp17.except]{\ref{except}: exception handling}
1959+
1960+
\diffref{except.spec}
1961+
\change Remove \tcode{throw()} exception specification.
1962+
\rationale
1963+
Removal of obsolete feature that has been replaced by \tcode{noexcept}.
1964+
\effect
1965+
A valid \CppXVII{} function declaration, member function declaration, function
1966+
pointer declaration, or function reference declaration that uses \tcode{throw()}
1967+
for its exception specification will be rejected as ill-formed in this
1968+
International Standard. It should simply be replaced with \tcode{noexcept} for no
1969+
change of meaning since \CppXVII{}.
1970+
\begin{note}
1971+
There is no way to write a function declaration
1972+
that is non-throwing in this International Standard
1973+
and is also non-throwing in \CppIII{}
1974+
except by using the preprocessor to generate
1975+
a different token sequence in each case.
1976+
\end{note}
1977+
19901978
\rSec2[diff.cpp17.library]{\ref{library}: library introduction}
19911979

19921980
\diffref{headers}
19931981
\change New headers.
19941982
\rationale New functionality.
19951983
\effect
19961984
The following \Cpp{} headers are new:
1985+
\tcode{<bit>},
19971986
\tcode{<compare>},
1987+
\tcode{<concepts>},
1988+
\tcode{<contract>},
19981989
\tcode{<span>},
19991990
\tcode{<syncstream>}, and
20001991
\tcode{<version>}.
20011992
Valid \CppXVII{} code that \tcode{\#include}{s} headers with these names may be
20021993
invalid in this International Standard.
20031994

1995+
\diffref{headers}
1996+
\change Remove vacuous \Cpp{} header files.
1997+
\rationale
1998+
The empty headers implied a false requirement to achieve C compatibility with the \Cpp{} headers.
1999+
\effect
2000+
A valid \CppXVII{} program that \tcode{\#include}{s} any of the following headers may fail to compile:
2001+
\tcode{<ccomplex>},
2002+
\tcode{<ciso646>},
2003+
\tcode{<cstdalign>},
2004+
\tcode{<cstdbool>}, and
2005+
\tcode{<ctgmath>}.
2006+
To retain the same behavior:
2007+
\begin{itemize}
2008+
\item
2009+
a \tcode{\#include} of \tcode{<ccomplex>} can be replaced by
2010+
a \tcode{\#include} of \tcode{<complex>}\iref{complex.syn},
2011+
\item
2012+
a \tcode{\#include} of \tcode{<ctgmath>} can be replaced by
2013+
a \tcode{\#include} of \tcode{<cmath>}\iref{cmath.syn} and
2014+
a \tcode{\#include} of \tcode{<complex>},
2015+
and
2016+
\item
2017+
a \tcode{\#include} of
2018+
\tcode{<ciso646>},
2019+
\tcode{<cstdalign>}, or
2020+
\tcode{<cstdbool>}
2021+
can simply be removed.
2022+
\end{itemize}
2023+
20042024
\rSec2[diff.cpp17.containers]{\ref{containers}: containers library}
20052025

20062026
\diffrefs{forwardlist}{list}
@@ -2013,6 +2033,89 @@
20132033
Translation units compiled against this version of \Cpp{} may be incompatible with
20142034
translation units compiled against \CppXVII{}, either failing to link or having undefined behavior.
20152035

2036+
\rSec2[diff.cpp17.depr]{\ref{depr}: compatibility features}
2037+
2038+
\nodiffref
2039+
\change Remove \tcode{uncaught_exception}.
2040+
\rationale
2041+
The function did not have a clear specification when multiple exceptions were
2042+
active, and has been superseded by \tcode{uncaught_exceptions}.
2043+
\effect
2044+
A valid \CppXVII{} program that calls \tcode{std::uncaught_exception} may fail
2045+
to compile. It might be revised to use \tcode{std::uncaught_exceptions} instead,
2046+
for clear and portable semantics.
2047+
2048+
\nodiffref
2049+
\change Remove support for adaptable function API.
2050+
\rationale
2051+
The deprecated support relied on a limited convention that could not be
2052+
extended to support the general case or new language features. It has been
2053+
superseded by direct language support with \tcode{decltype}, and by the
2054+
\tcode{std::bind} and \tcode{std::not_fn} function templates.
2055+
\effect
2056+
A valid \CppXVII{} program that relies on the presence of \tcode{result_type},
2057+
\tcode{argument_type}, \tcode{first_argument_type}, or
2058+
\tcode{second_argument_type} in a standard library class may fail to compile. A
2059+
valid \CppXVII{} program that calls \tcode{not1} or \tcode{not2}, or uses the
2060+
class templates \tcode{unary_negate} or \tcode{binary_negate}, may fail to
2061+
compile.
2062+
2063+
\nodiffref
2064+
\change Remove redundant members from \tcode{std::allocator}.
2065+
\rationale
2066+
\tcode{std::allocator} was overspecified, encouraging direct usage in user containers
2067+
rather than relying on \tcode{std::allocator_traits}, leading to poor containers.
2068+
\effect
2069+
A valid \CppXVII{} program that directly makes use of the \tcode{pointer},
2070+
\tcode{const_pointer}, \tcode{reference}, \tcode{const_reference},
2071+
\tcode{rebind}, \tcode{address}, \tcode{construct}, \tcode{destroy}, or
2072+
\tcode{max_size} members of \tcode{std::allocator}, or that directly calls
2073+
\tcode{allocate} with an additional hint argument, may fail to compile.
2074+
2075+
\nodiffref
2076+
\change Remove \tcode{raw_memory_iterator}.
2077+
\rationale
2078+
The iterator encouraged use of algorithms that might throw exceptions, but did
2079+
not return the number of elements successfully constructed that might need to
2080+
be destroyed in order to avoid leaks.
2081+
\effect
2082+
A valid \CppXVII{} program that uses this iterator class may fail to compile.
2083+
2084+
\nodiffref
2085+
\change Remove temporary buffers API.
2086+
\rationale
2087+
The temporary buffer facility was intended to provide an efficient optimization
2088+
for small memory requests, but there is little evidence this was achieved in
2089+
practice, while requiring the user to provide their own exception-safe wrappers
2090+
to guard use of the facility in many cases.
2091+
\effect
2092+
A valid \CppXVII{} program that calls \tcode{get_temporary_buffer} or
2093+
\tcode{return_temporary_buffer} may fail to compile.
2094+
2095+
\nodiffref
2096+
\change Remove \tcode{shared_ptr::unique}.
2097+
\rationale
2098+
The result of a call to this member function is not reliable in the presence of
2099+
multiple threads and weak pointers. The member function \tcode{use_count} is
2100+
similarly unreliable, but has a clearer contract in such cases, and remains
2101+
available for well defined use in single-threaded cases.
2102+
\effect
2103+
A valid \CppXVII{} program that calls \tcode{unique} on a \tcode{shared_ptr}
2104+
object may fail to compile.
2105+
2106+
\diffref{depr.meta.types}
2107+
\change Remove deprecated type traits.
2108+
\rationale
2109+
The traits had unreliable or awkward interfaces. The \tcode{is_literal_type}
2110+
trait provided no way to detect which subset of constructors and member
2111+
functions of a type were declared \tcode{constexpr}. The \tcode{result_of}
2112+
trait had a surprising syntax that could not report the result of a regular
2113+
function type. It has been superseded by the \tcode{invoke_result} trait.
2114+
\effect
2115+
A valid \CppXVII{} program that relies on the \tcode{is_literal_type} or
2116+
\tcode{result_of} type traits, on the \tcode{is_literal_type_v} variable template,
2117+
or on the \tcode{result_of_t} alias template may fail to compile.
2118+
20162119
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
20172120
\rSec1[diff.library]{C standard library}
20182121
\indextext{library!C standard}%
@@ -2031,27 +2134,17 @@
20312134
in~\ref{depr.c.headers}, but their use is deprecated in \Cpp{}.
20322135

20332136
\pnum
2034-
There are no \Cpp{} headers for the C headers
2137+
There are no \Cpp{} headers for the C standard library's headers
20352138
\tcode{<stdatomic.h>}\indextext{\idxhdr{stdatomic.h}!absence thereof},
20362139
\tcode{<stdnoreturn.h>}\indextext{\idxhdr{stdnoreturn.h}!absence thereof},
20372140
and \tcode{<threads.h>}\indextext{\idxhdr{threads.h}!absence thereof},
2038-
nor are the C headers themselves part of \Cpp{}.
2141+
nor are these headers from the C standard library headers themselves part of \Cpp{}.
20392142

20402143
\pnum
2041-
The \Cpp{} headers \tcode{<ccomplex>}\indexhdr{ccomplex}\iref{depr.ccomplex.syn}
2042-
and \tcode{<ctgmath>}\indexhdr{ctgmath}\iref{depr.ctgmath.syn}, as well
2043-
as their corresponding C headers \tcode{<complex.h>}\indexhdr{complex.h}
2044-
and \tcode{<tgmath.h>}\indexhdr{tgmath.h}, do not contain any of the
2045-
content from the C standard library and instead merely include other headers
2046-
from the \Cpp{} standard library.
2047-
2048-
\pnum
2049-
The headers \tcode{<ciso646>}\indexhdr{ciso646},
2050-
\tcode{<cstdalign>}\indexhdr{cstdalign}\iref{depr.cstdalign.syn},
2051-
and \tcode{<cstdbool>}\indexhdr{cstdbool}\iref{depr.cstdbool.syn}
2052-
are meaningless in \Cpp{}. Use of
2053-
the \Cpp{} headers \tcode{<ccomplex>}, \tcode{<cstdalign>}, \tcode{<cstdbool>},
2054-
and \tcode{<ctgmath>} is deprecated\iref{depr.c.headers}.
2144+
The C headers \tcode{<complex.h>}\indexhdr{complex.h} and
2145+
\tcode{<tgmath.h>}\indexhdr{tgmath.h} do not contain any of the content from
2146+
the C standard library and instead merely include other headers from the \Cpp{}
2147+
standard library.
20552148

20562149
\rSec2[diff.mods.to.definitions]{Modifications to definitions}
20572150

@@ -2103,27 +2196,27 @@
21032196
and
21042197
\tcode{xor_eq}
21052198
are keywords in this International
2106-
Standard\iref{lex.key}.
2107-
They do not appear as macro names defined in
2108-
\tcode{<ciso646>}.
2109-
\indexhdr{ciso646}%
2199+
Standard\iref{lex.key},
2200+
and are not introduced as macros
2201+
by \tcode{<iso646.h>}\iref{depr.iso646.h.syn}.
21102202

21112203
\rSec3[diff.header.stdalign.h]{Header \tcode{<stdalign.h>}}
21122204
\indexhdr{stdalign.h}%
21132205

21142206
\pnum
21152207
The token \tcode{alignas} is a keyword in this International
2116-
Standard\iref{lex.key}. It does not appear as a macro name defined
2117-
in \tcode{<cstdalign>}\indexhdr{cstdalign}\iref{depr.cstdalign.syn}.
2208+
Standard\iref{lex.key},
2209+
and is not introduced as a macro
2210+
by \tcode{<stdalign.h>}\iref{depr.stdalign.h.syn}.
21182211

21192212
\rSec3[diff.header.stdbool.h]{Header \tcode{<stdbool.h>}}
21202213
\indexhdr{stdbool.h}%
21212214

21222215
\pnum
21232216
The tokens \tcode{bool}, \tcode{true}, and \tcode{false}
2124-
are keywords in this International Standard\iref{lex.key}.
2125-
They do not appear as macro names defined in
2126-
\tcode{<cstdbool>}\indexhdr{cstdbool}\iref{depr.cstdbool.syn}.
2217+
are keywords in this International Standard\iref{lex.key},
2218+
and are not introduced as macros
2219+
by \tcode{<stdbool.h>}\iref{depr.stdbool.h.syn}.
21272220

21282221
\rSec3[diff.null]{Macro \tcode{NULL}}
21292222

source/containers.tex

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5628,6 +5628,7 @@
56285628
friend class vector;
56295629
reference() noexcept;
56305630
public:
5631+
reference(const reference&) = default;
56315632
~reference();
56325633
operator bool() const noexcept;
56335634
reference& operator=(const bool x) noexcept;

source/exceptions.tex

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -705,7 +705,6 @@
705705
\nontermdef{noexcept-specifier}\br
706706
\terminal{noexcept} \terminal{(} constant-expression \terminal{)}\br
707707
\terminal{noexcept}\br
708-
\terminal{throw} \terminal{(} \terminal{)}
709708
\end{bnf}
710709

711710
\pnum
@@ -723,10 +722,6 @@
723722
is
724723
equivalent to the \grammarterm{noexcept-specifier}
725724
\tcode{noexcept(true)}.
726-
The \grammarterm{noexcept-specifier} \tcode{throw()}
727-
is deprecated\iref{depr.except.spec}, and
728-
equivalent to the \grammarterm{noexcept-specifier}
729-
\tcode{noexcept(true)}.
730725

731726
\pnum
732727
If a declaration of a function
@@ -920,7 +915,7 @@
920915
~A();
921916
};
922917
struct B {
923-
B() throw();
918+
B() noexcept;
924919
B(const B&) = default; // implicit exception specification is \tcode{noexcept(true)}
925920
B(B&&, int = (throw Y(), 0)) noexcept;
926921
~B() noexcept(false);

0 commit comments

Comments
 (0)