Skip to content

Commit 2764d46

Browse files
authored
Merge 2022-11 CWG Motion 1
P2709R0 Core Language Working Group "ready" issues for the November, 2022 meeting; excluding issues 2635 and 2602
2 parents fb0df97 + 568c342 commit 2764d46

10 files changed

+296
-108
lines changed

source/basic.tex

+26-17
Original file line numberDiff line numberDiff line change
@@ -882,6 +882,7 @@
882882
\item
883883
their object parameters have the same type.
884884
\end{itemize}
885+
\indextext{template!function!corresponding object parameter}%
885886
Two non-static member function templates have
886887
\defnadjx{corresponding}{object parameters}{object parameter} if:
887888
\begin{itemize}
@@ -894,6 +895,14 @@
894895
\item
895896
the types of their object parameters are equivalent.
896897
\end{itemize}
898+
\indextext{template!function!corresponding signature}%
899+
Two function templates have
900+
\defnadjx{corresponding}{signatures}{signature} if
901+
their \grammarterm{template-parameter-list}{s}
902+
have the same length,
903+
their corresponding \grammarterm{template-parameter}{s} are equivalent,
904+
they have equivalent non-object-parameter-type-lists and return types (if any), and,
905+
if both are non-static members, they have corresponding object parameters.
897906

898907
\pnum
899908
Two declarations \defn{correspond}
@@ -925,13 +934,9 @@
925934
if both are non-static members,
926935
they have corresponding object parameters, or
927936
\item
928-
both declare function templates with equivalent
929-
non-object-parameter-type-lists,
930-
return types (if any),
931-
\grammarterm{template-head}s, and
932-
trailing \grammarterm{requires-clause}s (if any), and,
933-
if both are non-static members,
934-
they have corresponding object parameters.
937+
both declare function templates with corresponding signatures and equivalent
938+
\grammarterm{template-head}s and
939+
trailing \grammarterm{requires-clause}s (if any).
935940
\end{itemize}
936941
\end{itemize}
937942
\begin{note}
@@ -3426,8 +3431,7 @@
34263431
program has undefined behavior if:
34273432
\begin{itemize}
34283433
\item
3429-
the object will be or was of a class type with a non-trivial destructor
3430-
and the pointer is used as the operand of a \grammarterm{delete-expression},
3434+
the pointer is used as the operand of a \grammarterm{delete-expression},
34313435
\item
34323436
the pointer is used to access a non-static data member or call a
34333437
non-static member function of the object, or
@@ -4742,15 +4746,20 @@
47424746
has all of the following properties:
47434747
\begin{itemize}
47444748
\item it has a constexpr destructor\iref{dcl.constexpr},
4745-
\item it is either a closure type\iref{expr.prim.lambda.closure},
4746-
an aggregate type\iref{dcl.init.aggr}, or
4747-
has at least one constexpr constructor or constructor template
4749+
\item all of its non-static non-variant data members and base classes are of non-volatile literal types, and
4750+
\item it
4751+
\begin{itemize}
4752+
\item is a closure type\iref{expr.prim.lambda.closure},
4753+
\item is an aggregate union type that has either
4754+
no variant members or
4755+
at least one variant member of non-volatile literal type,
4756+
\item is a non-union aggregate type for which
4757+
each of its anonymous union members
4758+
satisfies the above requirements for an aggregate union type, or
4759+
\item has at least one constexpr constructor or constructor template
47484760
(possibly inherited\iref{namespace.udecl} from a base class)
4749-
that is not a copy or move constructor,
4750-
\item if it is a union, at least one of its non-static data members is
4751-
of non-volatile literal type, and
4752-
\item if it is not a union, all of its non-static data members and base classes are
4753-
of non-volatile literal types.
4761+
that is not a copy or move constructor.
4762+
\end{itemize}
47544763
\end{itemize}
47554764
\end{itemize}
47564765
\begin{note}

source/classes.tex

+15-8
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@
305305
A class \tcode{S} is an \defnadj{implicit-lifetime}{class} if
306306
\begin{itemize}
307307
\item
308-
it is an aggregate or
308+
it is an aggregate whose destructor is not user-provided or
309309
\item
310310
it has at least one trivial eligible constructor and
311311
a trivial, non-deleted destructor.
@@ -605,10 +605,9 @@
605605
\end{note}
606606

607607
\pnum
608-
A class is considered a completely-defined object
609-
type\iref{term.incomplete.type} (or complete type) at the closing \tcode{\}} of
610-
the \grammarterm{class-specifier}.
611-
The class is regarded as complete within its complete-class contexts;
608+
A class is regarded as complete
609+
where its definition is reachable and
610+
within its complete-class contexts;
612611
otherwise it is regarded as incomplete within its own class
613612
\grammarterm{member-specification}.
614613

@@ -785,13 +784,21 @@
785784
The \defn{common initial sequence} of two standard-layout struct\iref{class.prop}
786785
types is the longest sequence of non-static data
787786
members and bit-fields in declaration order, starting with the first
788-
such entity in each of the structs, such that corresponding entities
787+
such entity in each of the structs, such that
788+
\begin{itemize}
789+
\item
790+
corresponding entities
789791
have layout-compatible types\iref{basic.types},
792+
\item
793+
corresponding entities have the same alignment requirements\iref{basic.align},
794+
\item
790795
either both entities are declared with
791796
the \tcode{no_unique_address} attribute\iref{dcl.attr.nouniqueaddr}
792-
or neither is,
793-
and either both entities are bit-fields with the same width
797+
or neither is, and
798+
\item
799+
either both entities are bit-fields with the same width
794800
or neither is a bit-field.
801+
\end{itemize}
795802
\begin{example}
796803
\begin{codeblock}
797804
struct A { int a; char b; };

source/compatibility.tex

+25
Original file line numberDiff line numberDiff line change
@@ -657,6 +657,31 @@
657657
}
658658
\end{codeblock}
659659

660+
\diffref{over.match.oper}
661+
\change
662+
Overload resolution may change for equality operators\iref{expr.eq}.
663+
\rationale
664+
Support calling \tcode{operator==} with reversed order of arguments.
665+
\effect
666+
Valid \CppXVII{} code that uses equality operators with conversion functions
667+
may be ill-formed or have different semantics in this revision of \Cpp{}.
668+
For example:
669+
\begin{codeblock}
670+
struct A {
671+
operator int() const { return 10; }
672+
};
673+
674+
bool operator==(A, int); // \#1
675+
// \#2 is built-in candidate: \tcode{bool operator==(int, int);}
676+
bool b = 10 == A(); // calls \#1 with reversed order of arguments; previously selected \#2
677+
678+
struct B {
679+
bool operator==(const B&); // member function with no cv-qualifier
680+
};
681+
B b1;
682+
bool eq = (b1 == b1); // ambiguous; previously well-formed
683+
\end{codeblock}
684+
660685
\rSec2[diff.cpp17.temp]{\ref{temp}: templates}
661686

662687
\diffref{temp.names}

source/declarations.tex

+70-18
Original file line numberDiff line numberDiff line change
@@ -2323,12 +2323,16 @@
23232323
\pnum
23242324
The ambiguity arising from the similarity between a function-style cast and
23252325
a declaration mentioned in~\ref{stmt.ambig} can also occur in the context of a declaration.
2326-
In that context, the choice is between a function declaration with
2327-
a redundant set of parentheses around a parameter name and an object declaration
2328-
with a function-style cast as the initializer.
2326+
In that context, the choice is between
2327+
an object declaration
2328+
with a function-style cast as the initializer and
2329+
a declaration involving a function declarator
2330+
with a redundant set of parentheses around a parameter name.
23292331
Just as for the ambiguities mentioned in~\ref{stmt.ambig},
2330-
the resolution is to consider any construct that could possibly
2331-
be a declaration a declaration.
2332+
the resolution is to consider any construct,
2333+
such as the potential parameter declaration,
2334+
that could possibly be a declaration
2335+
to be a declaration.
23322336
\begin{note}
23332337
A declaration can be explicitly disambiguated by adding parentheses
23342338
around the argument.
@@ -4455,7 +4459,8 @@
44554459
as well as in argument passing, function return,
44564460
throwing an exception\iref{except.throw},
44574461
handling an exception\iref{except.handle},
4458-
and aggregate member initialization\iref{dcl.init.aggr},
4462+
and aggregate member initialization other than by a
4463+
\grammarterm{designated-initializer-clause}\iref{dcl.init.aggr},
44594464
is called
44604465
\defn{copy-initialization}.
44614466
\begin{note}
@@ -4548,7 +4553,7 @@
45484553
is the same class as the class of the destination,
45494554
the initializer expression is used to initialize the destination object.
45504555
\begin{example}
4551-
\tcode{T x = T(T(T()));} calls the \tcode{T} default constructor to initialize \tcode{x}.
4556+
\tcode{T x = T(T(T()));} value-initializes \tcode{x}.
45524557
\end{example}
45534558
\item
45544559
Otherwise, if the initialization is direct-initialization,
@@ -4680,6 +4685,14 @@
46804685
An \grammarterm{initializer-clause} followed by an ellipsis is a
46814686
pack expansion\iref{temp.variadic}.
46824687

4688+
\pnum
4689+
Initialization includes
4690+
the evaluation of all subexpressions of
4691+
each \grammarterm{initializer-clause} of
4692+
the initializer (possibly nested within \grammarterm{braced-init-list}{s}) and
4693+
the creation of any temporary objects for
4694+
function arguments or return values\iref{class.temporary}.
4695+
46834696
\pnum
46844697
If the initializer is a parenthesized \grammarterm{expression-list},
46854698
the expressions are evaluated in the order
@@ -4736,9 +4749,9 @@
47364749
\item
47374750
no private or protected direct non-static data members\iref{class.access},
47384751
\item
4739-
no virtual functions\iref{class.virtual}, and
4752+
no private or protected direct base classes\iref{class.access.base}, and
47404753
\item
4741-
no virtual, private, or protected base classes\iref{class.mi}.
4754+
no virtual functions\iref{class.virtual} or virtual base classes\iref{class.mi}.
47424755
\end{itemize}
47434756
\begin{note}
47444757
Aggregate initialization does not allow accessing
@@ -4790,7 +4803,7 @@
47904803
the initializer list is
47914804
a brace-enclosed \grammarterm{designated-initializer-list},
47924805
the element is initialized by the
4793-
\grammarterm{designated-initializer-list} \tcode{\{ }\placeholder{D}\tcode{ \}},
4806+
\grammarterm{braced-init-list} \tcode{\{ }\placeholder{D}\tcode{ \}},
47944807
where \placeholder{D} is the \grammarterm{designated-initializer-clause}
47954808
naming a member of the anonymous union member.
47964809
There shall be only one such \grammarterm{designated-initializer-clause}.
@@ -4818,6 +4831,11 @@
48184831
a narrowing conversion\iref{dcl.init.list} is required
48194832
to convert the expression, the program is ill-formed.
48204833
\begin{note}
4834+
If the initialization is by \grammarterm{designated-initializer-clause},
4835+
its form determines whether copy-initialization or direct-initialization
4836+
is performed.
4837+
\end{note}
4838+
\begin{note}
48214839
If an initializer is itself an initializer list,
48224840
the element is list-initialized, which will result in a recursive application
48234841
of the rules in this subclause if the element is an aggregate.
@@ -5975,8 +5993,18 @@
59755993
original type, or
59765994

59775995
\item from an integer type or unscoped enumeration type to an integer type that cannot
5978-
represent all the values of the original type, except where the source is a constant
5996+
represent all the values of the original type, except where
5997+
\begin{itemize}
5998+
\item
5999+
the source is a bit-field whose width $w$ is less than that of its type
6000+
(or, for an enumeration type, its underlying type) and
6001+
the target type can represent all the values
6002+
of a hypothetical extended integer type
6003+
with width $w$ and with the same signedness as the original type or
6004+
\item
6005+
the source is a constant
59796006
expression whose value after integral promotions will fit into the target type, or
6007+
\end{itemize}
59806008

59816009
\item from a pointer type or a pointer-to-member type to \tcode{bool}.
59826010
\end{itemize}
@@ -6448,19 +6476,20 @@
64486476
where
64496477
\begin{itemize}
64506478
\item
6479+
\indextext{coroutine!await expression}%
64516480
the \grammarterm{await-expression} containing
64526481
the call to \tcode{initial_suspend}
6453-
is the \defn{initial suspend point}, and
6482+
is the \defnadj{initial}{await expression}, and
64546483
\item
64556484
the \grammarterm{await-expression} containing
64566485
the call to \tcode{final_suspend}
6457-
is the \defn{final suspend point}, and
6486+
is the \defnadj{final}{await expression}, and
64586487
\item
64596488
\placeholder{initial-await-resume-called}
64606489
is initially \tcode{false} and is set to \tcode{true}
64616490
immediately before the evaluation
64626491
of the \placeholder{await-resume} expression\iref{expr.await}
6463-
of the initial suspend point, and
6492+
of the initial await expression, and
64646493
\item
64656494
\placeholder{promise-type} denotes the promise type, and
64666495
\item
@@ -6476,7 +6505,19 @@
64766505
constructor is found\iref{over.match.viable}, then
64776506
\placeholder{promise-constructor-arguments} is
64786507
\tcode{($\tcode{q}_1$, $\dotsc$, $\tcode{q}_n$)}, otherwise
6479-
\placeholder{promise-constructor-arguments} is empty.
6508+
\placeholder{promise-constructor-arguments} is empty, and
6509+
\item
6510+
a coroutine is suspended at the \defnadj{initial}{suspend point} if
6511+
it is suspended at the initial await expression, and
6512+
\item
6513+
a coroutine is suspended at a \defnadj{final}{suspend point} if
6514+
it is suspended
6515+
\begin{itemize}
6516+
\item
6517+
at a final await expression or
6518+
\item
6519+
due to an exception exiting from \tcode{unhandled_exception()}.
6520+
\end{itemize}
64806521
\end{itemize}
64816522

64826523
\pnum
@@ -6504,7 +6545,7 @@
65046545
a resumption member function\iref{coroutine.handle.resumption}
65056546
of a coroutine handle\iref{coroutine.handle}
65066547
that refers to the coroutine.
6507-
The function that invoked a resumption member function is
6548+
The evaluation that invoked a resumption member function is
65086549
called the \defnx{resumer}{coroutine!resumer}.
65096550
Invoking a resumption member function for a coroutine
65106551
that is not suspended results in undefined behavior.
@@ -6642,7 +6683,8 @@
66426683
\pnum
66436684
If the evaluation of the expression
66446685
\tcode{\exposid{promise}.unhandled_exception()} exits via an exception,
6645-
the coroutine is considered suspended at the final suspend point.
6686+
the coroutine is considered suspended at the final suspend point
6687+
and the exception propagates to the caller or resumer.
66466688

66476689
\pnum
66486690
The expression \keyword{co_await} \tcode{\exposid{promise}.final_suspend()}
@@ -7027,6 +7069,15 @@
70277069
this range.
70287070
\end{footnote}
70297071

7072+
\pnum
7073+
An enumeration has
7074+
the same size,
7075+
value representation, and
7076+
alignment requirements\iref{basic.align}
7077+
as its underlying type.
7078+
Furthermore, each value of an enumeration has the same representation
7079+
as the corresponding value of the underlying type.
7080+
70307081
\pnum
70317082
Two enumeration types are \defnx{layout-compatible enumerations}{layout-compatible!enumeration}
70327083
if they have the same underlying type.
@@ -8691,7 +8742,8 @@
86918742
a function,
86928743
a namespace,
86938744
an enumeration,
8694-
an enumerator, or
8745+
an enumerator,
8746+
a concept, or
86958747
a template specialization.
86968748

86978749
\pnum

0 commit comments

Comments
 (0)