Skip to content

[Motions 2024 03 cwg 1] P3196R0 (Core Language Working Group "ready" Issues) #6906

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 47 commits into from
Apr 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
47469c0
CWG453 References may only bind to “valid” objects
burblebee Mar 26, 2024
6bd8d0a
CWG1954 typeid null dereference check in subexpressions
burblebee Mar 26, 2024
939d5a5
CWG2476 placeholder-type-specifiers and function declarators
burblebee Mar 27, 2024
44a6d81
CWG2533 Storage duration of implicitly created objects
burblebee Mar 27, 2024
eef4c2b
CWG2546 Defaulted secondary comparison operators defined as deleted
burblebee Mar 27, 2024
5cd87e2
CWG2547 Defaulted comparison operator function for non-classes
burblebee Mar 27, 2024
bc3b802
CWG2560 Parameter type determination in a requirement-parameter-list
burblebee Mar 27, 2024
5227675
CWG2568 Access checking during synthesis of defaulted comparison oper…
burblebee Mar 27, 2024
90558db
CWG2634 Avoid circularity in specification of scope for friend class …
burblebee Mar 27, 2024
b391810
CWG2637 Injected-class-name as a simple-template-id
burblebee Mar 27, 2024
54e3829
CWG2638 Improve the example for initializing by initializer list
burblebee Mar 27, 2024
f0eb8e8
CWG2657 Cv-qualification adjustment when binding reference to temporary
burblebee Mar 27, 2024
2dc0d72
CWG2661 Missing disambiguation rule for pure-specifier vs. brace-or-e…
burblebee Mar 27, 2024
6a2476a
CWG2668 co_await in a lambda-expression
burblebee Mar 27, 2024
c720e60
CWG2689 Are cv-qualified std::nullptr_t fundamental types?
burblebee Mar 27, 2024
2e4a603
CWG2700 #error disallows existing implementation practice
burblebee Mar 27, 2024
5c86660
CWG2707 Deduction guides cannot have a trailing requires-clause
burblebee Mar 27, 2024
5d64fb7
CWG2714 Implicit deduction guides omit properties from the parameter-…
burblebee Mar 27, 2024
4655655
CWG2745 Dependent odr-use in generic lambdas
burblebee Mar 27, 2024
1a2c390
CWG2746 Checking of default template arguments
burblebee Mar 27, 2024
5bd604c
CWG2748 Accessing static data members via null pointer
burblebee Mar 27, 2024
14a05c9
CWG2771 Transformation for unqualified-ids in address operator
burblebee Mar 27, 2024
c37fc84
CWG2775 Unclear argument type for copy of exception object
burblebee Mar 27, 2024
03f6db1
CWG2777 Type of id-expression denoting a template parameter object
burblebee Mar 27, 2024
8fb9318
CWG2803 Overload resolution for reference binding of similar types
burblebee Mar 27, 2024
440cef3
CWG2809 An implicit definition does not redeclare a function
burblebee Mar 27, 2024
76fcfea
CWG2810 Requiring the absence of diagnostics for templates
burblebee Mar 27, 2024
36961e8
CWG2811 Clarify "use" of main
burblebee Mar 27, 2024
03408d1
CWG2813 Class member access with prvalues
burblebee Mar 27, 2024
c6000ad
CWG2820 Value-initialization and default constructors
burblebee Mar 27, 2024
f6228d3
CWG2822 Side-effect-free pointer zap
burblebee Mar 27, 2024
6a36364
CWG2824 Copy-initialization of arrays
burblebee Mar 27, 2024
3bf7dac
CWG2825 Range-based for statement using a braced-init-list
burblebee Mar 27, 2024
0e026f5
CWG2828 Ambiguous interpretation of C-style cast
burblebee Mar 27, 2024
b37a8ce
CWG2830 Top-level cv-qualification should be ignored for list-initial…
burblebee Mar 27, 2024
5b089c3
CWG2831 Non-templated function definitions and requires-clauses
burblebee Mar 27, 2024
0149909
CWG2845 Make the closure type of a captureless lambda a structural type
burblebee Mar 27, 2024
a41b34e
CWG2846 Out-of-class definitions of explicit object member functions
burblebee Mar 27, 2024
69c86fa
CWG2848 Omitting an empty template argument list for explicit instant…
burblebee Mar 27, 2024
aef74c9
CWG2849 Parameter objects are not temporary objects
burblebee Mar 27, 2024
f8b0b5f
CWG2850 Unclear storage duration for function parameter objects
burblebee Mar 27, 2024
8811f8a
CWG2851 Allow floating-point conversions in converted constant expres…
burblebee Mar 27, 2024
e611b75
CWG2853 Pointer arithmetic with pointer to hypothetical element
burblebee Mar 27, 2024
10bddc9
CWG2854 Storage duration of exception objects
burblebee Mar 27, 2024
c95348a
CWG2855 Undefined behavior in postfix increment
burblebee Mar 27, 2024
6b3f68b
CWG2856 Copy-list-initialization with explicit default constructors
burblebee Mar 27, 2024
d0bd27d
CWG2857 Argument-dependent lookup with incomplete class types
burblebee Mar 27, 2024
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
125 changes: 78 additions & 47 deletions source/basic.tex
Original file line number Diff line number Diff line change
Expand Up @@ -465,8 +465,8 @@

\pnum
\tcode{*\keyword{this}} is odr-used if \keyword{this} appears as a potentially-evaluated expression
(including as the result of the implicit transformation in the body of a non-static
member function\iref{class.mfct.non.static}).
(including as the result of any implicit transformation to
a class member access expression\iref{expr.prim.id.general}).

\pnum
A virtual member
Expand Down Expand Up @@ -537,6 +537,27 @@
\end{codeblock}
\end{example}

\pnum
\begin{example}
\begin{codeblock}
void g() {
constexpr int x = 1;
auto lambda = [] <typename T, int = ((T)x, 0)> {}; // OK
lambda.operator()<int, 1>(); // OK, does not consider \tcode{x} at all
lambda.operator()<int>(); // OK, does not odr-use \tcode{x}
lambda.operator()<const int&>(); // error: odr-uses \tcode{x} from a context where \tcode{x} is not odr-usable
}

void h() {
constexpr int x = 1;
auto lambda = [] <typename T> { (T)x; }; // OK
lambda.operator()<int>(); // OK, does not odr-use \tcode{x}
lambda.operator()<void>(); // OK, does not odr-use \tcode{x}
lambda.operator()<const int&>(); // error: odr-uses \tcode{x} from a context where \tcode{x} is not odr-usable
}
\end{codeblock}
\end{example}

\pnum
Every program shall contain at least one definition of every
function or variable that is odr-used in that program
Expand Down Expand Up @@ -2034,7 +2055,7 @@
its associated entities are:
the class itself;
the class of which it is a member, if any;
and its direct and indirect base classes.
and, if it is a complete type, its direct and indirect base classes.
Furthermore, if \tcode{T} is a class template specialization,
its associated entities also include:
the entities
Expand Down Expand Up @@ -3809,38 +3830,27 @@
\item automatic storage duration
\item dynamic storage duration
\end{itemize}
\begin{note}
After the duration of a region of storage has ended,
the use of pointers to that region of storage is limited\iref{basic.compound}.
\end{note}

\pnum
\indextext{storage duration!static}%
\indextext{storage duration!thread}%
\indextext{storage duration!automatic}%
\indextext{storage duration!dynamic}%
Static, thread, and automatic storage durations are associated with objects
introduced by declarations\iref{basic.def} and implicitly created by
the implementation\iref{class.temporary}. The dynamic storage duration
introduced by declarations\iref{basic.def} and
with temporary objects\iref{class.temporary}.
The dynamic storage duration
is associated with objects created by a
\grammarterm{new-expression}\iref{expr.new}.
\grammarterm{new-expression}\iref{expr.new} or
with implicitly created objects\iref{intro.object}.

\pnum
The storage duration categories apply to references as well.

\pnum
When the end of the duration of a region of storage is reached,
the values of all pointers
representing the address of any part of that region of storage
become invalid pointer values\iref{basic.compound}.
Indirection through an invalid pointer value and
passing an invalid pointer value to a deallocation function
have undefined behavior.
Any other use of an invalid pointer value has
\impldef{any use of an invalid pointer other than to perform indirection or deallocate}
behavior.
\begin{footnote}
Some implementations might define that
copying an invalid pointer value
causes a system-generated runtime fault.
\end{footnote}

\rSec3[basic.stc.static]{Static storage duration}

\pnum
Expand Down Expand Up @@ -3897,15 +3907,16 @@

\pnum
\indextext{storage duration!local object}%
Variables that belong to a block or parameter scope and are
Variables that belong to a block scope and are
not explicitly declared \keyword{static}, \keyword{thread_local}, or \keyword{extern} have
\defnadj{automatic}{storage duration}. The storage
for these entities lasts until the block in which they are created exits.

\pnum
for such variables lasts until the block in which they are created exits.
\begin{note}
These variables are initialized and destroyed as described in~\ref{stmt.dcl}.
\end{note}
Variables that belong to a parameter scope also have automatic storage duration.
The storage for a function parameter lasts until
immediately after its destruction\iref{expr.call}.

\pnum
If a variable with automatic storage duration has initialization or a destructor with side
Expand Down Expand Up @@ -4285,15 +4296,9 @@
Temporary objects are created
\begin{itemize}
\item
when a prvalue is converted to an xvalue\iref{conv.rval},
when a prvalue is converted to an xvalue\iref{conv.rval} and
\item
when needed by the implementation to pass or return an object of trivially copyable type (see below),
and
\item
when throwing an exception\iref{except.throw}.
\begin{note}
The lifetime of exception objects is described in~\ref{except.throw}.
\end{note}
when needed by the implementation to pass or return an object of trivially copyable type (see below).
\end{itemize}
Even when the creation of the temporary object is
unevaluated\iref{expr.context},
Expand All @@ -4318,7 +4323,9 @@
when binding a reference to a prvalue\iref{dcl.init.ref,expr.type.conv,
expr.dynamic.cast,expr.static.cast,expr.const.cast,expr.cast},
\item
when performing member access on a class prvalue\iref{expr.ref,expr.mptr.oper},
when performing certain member accesses on a class prvalue\iref{expr.ref,expr.mptr.oper},
\item
when invoking an implicit object member function on a class prvalue\iref{expr.call},
\item
when performing an array-to-pointer conversion or subscripting on an array prvalue\iref{conv.array,expr.sub},
\item
Expand Down Expand Up @@ -4541,18 +4548,21 @@
\end{itemize}

\pnum
The fourth context is when a temporary object other than a function parameter object
The fourth context is when a temporary object
is created in the \grammarterm{for-range-initializer} of a range-based \keyword{for} statement.
If such a temporary object would otherwise be destroyed
at the end of the \grammarterm{for-range-initializer} full-expression,
the object persists for the lifetime of the reference
initialized by the \grammarterm{for-range-initializer}.

\pnum
The destruction of a temporary whose lifetime is not extended
beyond the full-expression in which it was created
is sequenced before the destruction of every
temporary which is constructed earlier in the same full-expression.
Let \tcode{x} and \tcode{y} each be either
a temporary object whose lifetime is not extended, or
a function parameter.
If the lifetimes of \tcode{x} and \tcode{y} end at
the end of the same full-expression, and
\tcode{x} is initialized before \tcode{y}, then
the destruction of \tcode{y} is sequenced before that of \tcode{x}.
If the lifetime of two or more temporaries
with lifetimes extending beyond the full-expressions in which they were created
ends at the same point,
Expand Down Expand Up @@ -5207,6 +5217,7 @@
to type \cv{}~\keyword{void}.

\pnum
The types denoted by \cv~\tcode{std::nullptr_t} are distinct types.
A value of type \tcode{std::nullptr_t} is a null pointer
constant\iref{conv.ptr}. Such values participate in the pointer and the
pointer-to-member conversions\iref{conv.ptr,conv.mem}.
Expand Down Expand Up @@ -5416,10 +5427,6 @@
is not considered to point to an unrelated object
of the object's type,
even if the unrelated object is located at that address.
A pointer value becomes invalid
when the storage it denotes
reaches the end of its storage duration;
see \ref{basic.stc}.
\end{note}
For purposes of pointer arithmetic\iref{expr.add}
and comparison\iref{expr.rel,expr.eq},
Expand All @@ -5440,6 +5447,31 @@
alignment requirement.
\end{note}

\pnum
A pointer value $P$ is
\indextext{value!valid in the context of an evaluation}%
\defn{valid in the context of} an evaluation $E$
if $P$ is a null pointer value, or
if it is a pointer to or past the end of an object $O$ and
$E$ happens before the end of the duration of the region of storage for $O$.
If a pointer value $P$ is used in an evaluation $E$ and
$P$ is not valid in the context of $E$,
then the behavior is undefined if $E$ is
an indirection\iref{expr.unary.op} or
an invocation of a deallocation function\iref{basic.stc.dynamic.deallocation},
and \impldef{invalid pointer value in the context of an evaluation} otherwise.
\begin{footnote}
Some implementations might define that
copying such a pointer value causes a system-generated runtime fault.
\end{footnote}
\begin{note}
$P$ can be valid in the context of $E$ even
if it points to a type unrelated to that of $O$ or
if $O$ is not within its lifetime,
although further restrictions apply
to such pointer values\iref{basic.life, basic.lval, expr.add}.
\end{note}

\pnum
Two objects \placeholder{a} and \placeholder{b} are \defn{pointer-interconvertible} if:
\begin{itemize}
Expand Down Expand Up @@ -6703,8 +6735,7 @@
Any further (optional) parameters should be added after \tcode{argv}.

\pnum
The function \tcode{main} shall not be used within
a program.
The function \tcode{main} shall not be named by an expression.
\indextext{\idxcode{main} function!implementation-defined linkage of}%
The linkage\iref{basic.link} of \tcode{main} is
\impldef{linkage of \tcode{main}}. A program that defines \tcode{main} as
Expand Down
Loading