Skip to content

Commit fed66c0

Browse files
authored
Merge 2022-07 CWG Motion 1
P2622R0 Core Language Working Group "ready" Issues for the July, 2022 meeting
2 parents 78b91e8 + dfa3d7e commit fed66c0

File tree

8 files changed

+184
-73
lines changed

8 files changed

+184
-73
lines changed

source/basic.tex

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1564,7 +1564,7 @@
15641564
The result of the search is the declaration set of $S(N,T)$.
15651565
If it is an invalid set, the program is ill-formed.
15661566
If it differs from the result of a search in $T$ for $N$
1567-
from immediately after the \grammarterm{class-specifier} of $T$,
1567+
in a complete-class context\iref{class.mem} of $T$,
15681568
the program is ill-formed, no diagnostic required.
15691569
\begin{example}
15701570
\begin{codeblock}
@@ -3829,7 +3829,9 @@
38293829
\pnum
38303830
The library provides default definitions for the global allocation and
38313831
deallocation functions. Some global allocation and deallocation
3832-
functions are replaceable\iref{new.delete}. A \Cpp{} program shall
3832+
functions are replaceable\iref{new.delete};
3833+
these are attached to the global module\iref{module.unit}.
3834+
A \Cpp{} program shall
38333835
provide at most one definition of a replaceable allocation or
38343836
deallocation function. Any such function definition replaces the default
38353837
version provided in the library\iref{replacement.functions}. The
@@ -6382,12 +6384,19 @@
63826384
The function \tcode{main} shall not be a coroutine\iref{dcl.fct.def.coroutine}.
63836385
The \tcode{main} function shall not be declared with a
63846386
\grammarterm{linkage-specification}\iref{dcl.link}.
6385-
A program
6386-
that declares a variable \tcode{main} that belongs to the global scope, or
6387-
that declares a function \tcode{main} that belongs to the global scope and
6387+
A program that declares
6388+
\begin{itemize}
6389+
\item
6390+
a variable \tcode{main} that belongs to the global scope, or
6391+
\item
6392+
a function \tcode{main} that belongs to the global scope and
63886393
is attached to a named module, or
6389-
that declares an entity named \tcode{main}
6394+
\item
6395+
a function template \tcode{main} that belongs to the global scope, or
6396+
\item
6397+
an entity named \tcode{main}
63906398
with C language linkage (in any namespace)
6399+
\end{itemize}
63916400
is ill-formed.
63926401
The name \tcode{main} is
63936402
not otherwise reserved.

source/classes.tex

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -931,12 +931,6 @@
931931
its class or a class derived from its class, or
932932
a member thereof, as described below.
933933

934-
\pnum
935-
\indextext{member function!call undefined}%
936-
If a non-static member function of a class \tcode{X} is called for an
937-
object that is not of type \tcode{X}, or of a type derived from
938-
\tcode{X}, the behavior is undefined.
939-
940934
\pnum
941935
When an \grammarterm{id-expression}\iref{expr.prim.id} that is not part of a
942936
class member access syntax\iref{expr.ref} and not used to form a

source/compatibility.tex

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,24 @@
5555
// now equivalent to \tcode{arr.operator[](1, 2)} or ill-formed
5656
\end{codeblock}
5757

58+
\rSec2[diff.cpp20.temp]{\ref{temp}: templates}
59+
60+
\diffref{temp.deduct.type}
61+
\change
62+
Deducing template arguments from exception specifications.
63+
\rationale
64+
Facilitate generic handling of throwing and non-throwing functions.
65+
\effect
66+
Valid ISO \CppXX{} code may be ill-formed in this revision of \Cpp{}.
67+
\begin{codeblock}
68+
template<bool> struct A { };
69+
template<bool B> void f(void (*)(A<B>) noexcept(B));
70+
void g(A<false>) noexcept;
71+
void h() {
72+
f(g); // ill-formed; previously well-formed
73+
}
74+
\end{codeblock}
75+
5876
\rSec2[diff.cpp20.library]{\ref{library}: library introduction}
5977

6078
\diffref{headers}

source/declarations.tex

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6563,18 +6563,20 @@
65636563
The allocation function's name is looked up by searching for it in the scope of the promise type.
65646564
\begin{itemize}
65656565
\item
6566-
If any declarations are found,
6566+
If the search finds any declarations,
65676567
overload resolution is performed on a function call created by assembling an
6568-
argument list. The first argument is the amount of space requested, and has
6569-
type \tcode{std::size_t}.
6570-
The lvalues $\tcode{p}_1 \dotsc \tcode{p}_n$ are the succeeding arguments.
6571-
\item
6572-
Otherwise, a search is performed in the global scope.
6573-
\end{itemize}
6568+
argument list. The first argument is the amount of space requested, and
6569+
is a prvalue of type \tcode{std::size_t}.
6570+
The lvalues $\tcode{p}_1 \dotsc \tcode{p}_n$ are the successive arguments.
65746571
If no viable function is found\iref{over.match.viable},
65756572
overload resolution is performed again
65766573
on a function call created by passing just
6577-
the amount of space required as an argument of type \tcode{std::size_t}.
6574+
the amount of space required as a prvalue of type \tcode{std::size_t}.
6575+
\item
6576+
If the search finds no declarations, a search is performed in the global scope.
6577+
Overload resolution is performed on a function call created by
6578+
passing the amount of space required as a prvalue of type \tcode{std::size_t}.
6579+
\end{itemize}
65786580

65796581
\pnum
65806582
If a search for the name \tcode{get_return_object_on_allocation_failure}

source/expressions.tex

Lines changed: 37 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3057,9 +3057,17 @@
30573057
A \defnadj{subscript}{expression} is a postfix expression
30583058
followed by square brackets containing
30593059
a possibly empty, comma-separated list of \grammarterm{initializer-clause}s
3060-
which constitute the arguments to the subscript operator.
3061-
The \grammarterm{postfix-expression} is sequenced before
3062-
each expression in the \grammarterm{expression-list}.
3060+
that constitute the arguments to the subscript operator.
3061+
The \grammarterm{postfix-expression} and
3062+
the initialization of the object parameter of
3063+
any applicable subscript operator function is sequenced before
3064+
each expression in the \grammarterm{expression-list} and also before
3065+
any default argument.
3066+
The initialization of a non-object parameter of
3067+
a subscript operator function \tcode{S}\iref{over.sub},
3068+
including every associated value computation and side effect,
3069+
is indeterminately sequenced with respect to that of
3070+
any other non-object parameter of \tcode{S}.
30633071

30643072
\pnum
30653073
With the built-in subscript operator,
@@ -3478,7 +3486,7 @@
34783486
If the object expression is of scalar type,
34793487
\tcode{E2} shall name the pseudo-destructor
34803488
of that same type (ignoring cv-qualifications) and
3481-
\tcode{E1.E2} is an lvalue of type ``function of () returning \keyword{void}''.
3489+
\tcode{E1.E2} is a prvalue of type ``function of () returning \keyword{void}''.
34823490
\begin{note}
34833491
This value can only be used
34843492
for a notional function call\iref{expr.prim.id.dtor}.
@@ -3561,15 +3569,33 @@
35613569
\end{itemize}
35623570

35633571
\pnum
3564-
If \tcode{E2} is a non-static data member or a non-static member
3565-
function, the program is ill-formed if the class of which \tcode{E2} is
3572+
If \tcode{E2} is a non-static member,
3573+
the program is ill-formed if the class of which \tcode{E2} is
35663574
directly a member is an ambiguous base\iref{class.member.lookup} of
35673575
the naming class\iref{class.access.base} of \tcode{E2}.
35683576
\begin{note}
35693577
The program is also ill-formed if the naming class is an ambiguous base of the class type
35703578
of the object expression; see~\ref{class.access.base}.
35713579
\end{note}
35723580

3581+
\pnum
3582+
If \tcode{E2} is a non-static member and
3583+
the result of \tcode{E1} is an object whose type
3584+
is not similar\iref{conv.qual} to the type of \tcode{E1},
3585+
the behavior is undefined.
3586+
\begin{example}
3587+
\begin{codeblock}
3588+
struct A { int i; };
3589+
struct B { int j; };
3590+
struct D : A, B {};
3591+
void f() {
3592+
D d;
3593+
static_cast<B&>(d).j; // OK, object expression designates the \tcode{B} subobject of \tcode{d}
3594+
reinterpret_cast<B&>(d).j; // undefined behavior
3595+
}
3596+
\end{codeblock}
3597+
\end{example}
3598+
35733599
\rSec3[expr.post.incr]{Increment and decrement}
35743600

35753601
\pnum
@@ -4080,7 +4106,7 @@
40804106
\tcode{A} does not satisfy the alignment requirement of \tcode{T},
40814107
then the resulting pointer value is unspecified.
40824108
Otherwise, if the original pointer value points to an object \placeholder{a},
4083-
and there is an object \placeholder{b} of type \tcode{T} (ignoring cv-qualification)
4109+
and there is an object \placeholder{b} of type similar to \tcode{T}
40844110
that is pointer-interconvertible\iref{basic.compound} with \placeholder{a},
40854111
the result is a pointer to \placeholder{b}.
40864112
Otherwise, the pointer value is unchanged by the conversion.
@@ -5939,10 +5965,12 @@
59395965
\pnum
59405966
Abbreviating \grammarterm{pm-expression}\tcode{.*}\grammarterm{cast-expression} as \tcode{E1.*E2}, \tcode{E1}
59415967
is called the \defn{object expression}.
5942-
If the dynamic type of \tcode{E1} does not
5968+
If the result of \tcode{E1} is an object
5969+
whose type is not similar to the type of \tcode{E1}, or
5970+
whose most derived object does not
59435971
contain the member to which
59445972
\tcode{E2} refers, the behavior is undefined.
5945-
Otherwise, the expression \tcode{E1} is sequenced before the expression \tcode{E2}.
5973+
The expression \tcode{E1} is sequenced before the expression \tcode{E2}.
59465974

59475975
\pnum
59485976
The restrictions on cv-qualification, and the manner in which

source/lex.tex

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1464,9 +1464,17 @@
14641464
A \grammarterm{character-literal} with
14651465
a \grammarterm{c-char-sequence} consisting of
14661466
a single \grammarterm{numeric-escape-sequence}
1467-
that specifies an integer value $v$ has a value as follows:
1467+
has a value as follows:
14681468
\begin{itemize}
14691469
\item
1470+
Let $v$ be the integer value represented by
1471+
the octal number comprising
1472+
the sequence of \grammarterm{octal-digit}{s} in
1473+
an \grammarterm{octal-escape-sequence} or by
1474+
the hexadecimal number comprising
1475+
the sequence of \grammarterm{hexadecimal-digit}{s} in
1476+
a \grammarterm{hexadecimal-escape-sequence}.
1477+
\item
14701478
If $v$ does not exceed
14711479
the range of representable values of the \grammarterm{character-literal}'s type,
14721480
then the value is $v$.
@@ -1922,10 +1930,17 @@
19221930
\end{note}
19231931
\item
19241932
Each \grammarterm{numeric-escape-sequence}\iref{lex.ccon}
1925-
that specifies an integer value $v$
19261933
contributes a single code unit with a value as follows:
19271934
\begin{itemize}
19281935
\item
1936+
Let $v$ be the integer value represented by
1937+
the octal number comprising
1938+
the sequence of \grammarterm{octal-digit}{s} in
1939+
an \grammarterm{octal-escape-sequence} or by
1940+
the hexadecimal number comprising
1941+
the sequence of \grammarterm{hexadecimal-digit}{s} in
1942+
a \grammarterm{hexadecimal-escape-sequence}.
1943+
\item
19291944
If $v$ does not exceed the range of representable values of
19301945
the \grammarterm{string-literal}'s array element type,
19311946
then the value is $v$.

source/modules.tex

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -148,10 +148,8 @@
148148
it is attached to the module to which the friend is attached\iref{basic.link}.
149149
\item Otherwise, if the declaration
150150
\begin{itemize}
151-
\item is a replaceable global allocation or deallocation
152-
function\iref{new.delete.single,new.delete.array}, or
153-
\item is a \grammarterm{namespace-definition} with external linkage, or
154-
\item appears within a \grammarterm{linkage-specification},
151+
\item is a \grammarterm{namespace-definition} with external linkage or
152+
\item appears within a \grammarterm{linkage-specification}\iref{dcl.link}
155153
\end{itemize}
156154
it is attached to the global module.
157155

0 commit comments

Comments
 (0)