Skip to content

[2022-07 CWG Motion 1] P2622R0 Core Defect Reports #5664

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Aug 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 15 additions & 6 deletions source/basic.tex
Original file line number Diff line number Diff line change
Expand Up @@ -1564,7 +1564,7 @@
The result of the search is the declaration set of $S(N,T)$.
If it is an invalid set, the program is ill-formed.
If it differs from the result of a search in $T$ for $N$
from immediately after the \grammarterm{class-specifier} of $T$,
in a complete-class context\iref{class.mem} of $T$,
the program is ill-formed, no diagnostic required.
\begin{example}
\begin{codeblock}
Expand Down Expand Up @@ -3829,7 +3829,9 @@
\pnum
The library provides default definitions for the global allocation and
deallocation functions. Some global allocation and deallocation
functions are replaceable\iref{new.delete}. A \Cpp{} program shall
functions are replaceable\iref{new.delete};
these are attached to the global module\iref{module.unit}.
A \Cpp{} program shall
provide at most one definition of a replaceable allocation or
deallocation function. Any such function definition replaces the default
version provided in the library\iref{replacement.functions}. The
Expand Down Expand Up @@ -6382,12 +6384,19 @@
The function \tcode{main} shall not be a coroutine\iref{dcl.fct.def.coroutine}.
The \tcode{main} function shall not be declared with a
\grammarterm{linkage-specification}\iref{dcl.link}.
A program
that declares a variable \tcode{main} that belongs to the global scope, or
that declares a function \tcode{main} that belongs to the global scope and
A program that declares
\begin{itemize}
\item
a variable \tcode{main} that belongs to the global scope, or
\item
a function \tcode{main} that belongs to the global scope and
is attached to a named module, or
that declares an entity named \tcode{main}
\item
a function template \tcode{main} that belongs to the global scope, or
\item
an entity named \tcode{main}
with C language linkage (in any namespace)
\end{itemize}
is ill-formed.
The name \tcode{main} is
not otherwise reserved.
Expand Down
6 changes: 0 additions & 6 deletions source/classes.tex
Original file line number Diff line number Diff line change
Expand Up @@ -931,12 +931,6 @@
its class or a class derived from its class, or
a member thereof, as described below.

\pnum
\indextext{member function!call undefined}%
If a non-static member function of a class \tcode{X} is called for an
object that is not of type \tcode{X}, or of a type derived from
\tcode{X}, the behavior is undefined.

\pnum
When an \grammarterm{id-expression}\iref{expr.prim.id} that is not part of a
class member access syntax\iref{expr.ref} and not used to form a
Expand Down
18 changes: 18 additions & 0 deletions source/compatibility.tex
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,24 @@
// now equivalent to \tcode{arr.operator[](1, 2)} or ill-formed
\end{codeblock}

\rSec2[diff.cpp20.temp]{\ref{temp}: templates}

\diffref{temp.deduct.type}
\change
Deducing template arguments from exception specifications.
\rationale
Facilitate generic handling of throwing and non-throwing functions.
\effect
Valid ISO \CppXX{} code may be ill-formed in this revision of \Cpp{}.
\begin{codeblock}
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{codeblock}

\rSec2[diff.cpp20.library]{\ref{library}: library introduction}

\diffref{headers}
Expand Down
18 changes: 10 additions & 8 deletions source/declarations.tex
Original file line number Diff line number Diff line change
Expand Up @@ -6563,18 +6563,20 @@
The allocation function's name is looked up by searching for it in the scope of the promise type.
\begin{itemize}
\item
If any declarations are found,
If the search finds any declarations,
overload resolution is performed on a function call created by assembling an
argument list. The first argument is the amount of space requested, and has
type \tcode{std::size_t}.
The lvalues $\tcode{p}_1 \dotsc \tcode{p}_n$ are the succeeding arguments.
\item
Otherwise, a search is performed in the global scope.
\end{itemize}
argument list. The first argument is the amount of space requested, and
is a prvalue of type \tcode{std::size_t}.
The lvalues $\tcode{p}_1 \dotsc \tcode{p}_n$ are the successive arguments.
If no viable function is found\iref{over.match.viable},
overload resolution is performed again
on a function call created by passing just
the amount of space required as an argument of type \tcode{std::size_t}.
the amount of space required as a prvalue of type \tcode{std::size_t}.
\item
If the search finds no declarations, a search is performed in the global scope.
Overload resolution is performed on a function call created by
passing the amount of space required as a prvalue of type \tcode{std::size_t}.
\end{itemize}

\pnum
If a search for the name \tcode{get_return_object_on_allocation_failure}
Expand Down
46 changes: 37 additions & 9 deletions source/expressions.tex
Original file line number Diff line number Diff line change
Expand Up @@ -3057,9 +3057,17 @@
A \defnadj{subscript}{expression} is a postfix expression
followed by square brackets containing
a possibly empty, comma-separated list of \grammarterm{initializer-clause}s
which constitute the arguments to the subscript operator.
The \grammarterm{postfix-expression} is sequenced before
each expression in the \grammarterm{expression-list}.
that constitute the arguments to the subscript operator.
The \grammarterm{postfix-expression} and
the initialization of the object parameter of
any applicable subscript operator function is sequenced before
each expression in the \grammarterm{expression-list} and also before
any default argument.
The initialization of a non-object parameter of
a subscript operator function \tcode{S}\iref{over.sub},
including every associated value computation and side effect,
is indeterminately sequenced with respect to that of
any other non-object parameter of \tcode{S}.

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

\pnum
If \tcode{E2} is a non-static data member or a non-static member
function, the program is ill-formed if the class of which \tcode{E2} is
If \tcode{E2} is a non-static member,
the program is ill-formed if the class of which \tcode{E2} is
directly a member is an ambiguous base\iref{class.member.lookup} of
the naming class\iref{class.access.base} of \tcode{E2}.
\begin{note}
The program is also ill-formed if the naming class is an ambiguous base of the class type
of the object expression; see~\ref{class.access.base}.
\end{note}

\pnum
If \tcode{E2} is a non-static member and
the result of \tcode{E1} is an object whose type
is not similar\iref{conv.qual} to the type of \tcode{E1},
the behavior is undefined.
\begin{example}
\begin{codeblock}
struct A { int i; };
struct B { int j; };
struct D : A, B {};
void f() {
D d;
static_cast<B&>(d).j; // OK, object expression designates the \tcode{B} subobject of \tcode{d}
reinterpret_cast<B&>(d).j; // undefined behavior
}
\end{codeblock}
\end{example}

\rSec3[expr.post.incr]{Increment and decrement}

\pnum
Expand Down Expand Up @@ -4080,7 +4106,7 @@
\tcode{A} does not satisfy the alignment requirement of \tcode{T},
then the resulting pointer value is unspecified.
Otherwise, if the original pointer value points to an object \placeholder{a},
and there is an object \placeholder{b} of type \tcode{T} (ignoring cv-qualification)
and there is an object \placeholder{b} of type similar to \tcode{T}
that is pointer-interconvertible\iref{basic.compound} with \placeholder{a},
the result is a pointer to \placeholder{b}.
Otherwise, the pointer value is unchanged by the conversion.
Expand Down Expand Up @@ -5939,10 +5965,12 @@
\pnum
Abbreviating \grammarterm{pm-expression}\tcode{.*}\grammarterm{cast-expression} as \tcode{E1.*E2}, \tcode{E1}
is called the \defn{object expression}.
If the dynamic type of \tcode{E1} does not
If the result of \tcode{E1} is an object
whose type is not similar to the type of \tcode{E1}, or
whose most derived object does not
contain the member to which
\tcode{E2} refers, the behavior is undefined.
Otherwise, the expression \tcode{E1} is sequenced before the expression \tcode{E2}.
The expression \tcode{E1} is sequenced before the expression \tcode{E2}.

\pnum
The restrictions on cv-qualification, and the manner in which
Expand Down
19 changes: 17 additions & 2 deletions source/lex.tex
Original file line number Diff line number Diff line change
Expand Up @@ -1464,9 +1464,17 @@
A \grammarterm{character-literal} with
a \grammarterm{c-char-sequence} consisting of
a single \grammarterm{numeric-escape-sequence}
that specifies an integer value $v$ has a value as follows:
has a value as follows:
\begin{itemize}
\item
Let $v$ be the integer value represented by
the octal number comprising
the sequence of \grammarterm{octal-digit}{s} in
an \grammarterm{octal-escape-sequence} or by
the hexadecimal number comprising
the sequence of \grammarterm{hexadecimal-digit}{s} in
a \grammarterm{hexadecimal-escape-sequence}.
\item
If $v$ does not exceed
the range of representable values of the \grammarterm{character-literal}'s type,
then the value is $v$.
Expand Down Expand Up @@ -1922,10 +1930,17 @@
\end{note}
\item
Each \grammarterm{numeric-escape-sequence}\iref{lex.ccon}
that specifies an integer value $v$
contributes a single code unit with a value as follows:
\begin{itemize}
\item
Let $v$ be the integer value represented by
the octal number comprising
the sequence of \grammarterm{octal-digit}{s} in
an \grammarterm{octal-escape-sequence} or by
the hexadecimal number comprising
the sequence of \grammarterm{hexadecimal-digit}{s} in
a \grammarterm{hexadecimal-escape-sequence}.
\item
If $v$ does not exceed the range of representable values of
the \grammarterm{string-literal}'s array element type,
then the value is $v$.
Expand Down
6 changes: 2 additions & 4 deletions source/modules.tex
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,8 @@
it is attached to the module to which the friend is attached\iref{basic.link}.
\item Otherwise, if the declaration
\begin{itemize}
\item is a replaceable global allocation or deallocation
function\iref{new.delete.single,new.delete.array}, or
\item is a \grammarterm{namespace-definition} with external linkage, or
\item appears within a \grammarterm{linkage-specification},
\item is a \grammarterm{namespace-definition} with external linkage or
\item appears within a \grammarterm{linkage-specification}\iref{dcl.link}
\end{itemize}
it is attached to the global module.

Expand Down
Loading