Skip to content

Commit 98bf7ee

Browse files
eisenwavetkoeppe
authored andcommitted
CWG3063 Lifetime extension of temporaries past function return
Fixes NB CA 040 (C++26 CD).
1 parent dddbef9 commit 98bf7ee

3 files changed

Lines changed: 26 additions & 22 deletions

File tree

source/basic.tex

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3667,6 +3667,24 @@
36673667
the address of an unspecified byte of storage
36683668
occupied by the complete object of that subobject.
36693669

3670+
\pnum
3671+
The \defnx{constituent values}{constituent value} of an object $o$ are
3672+
\begin{itemize}
3673+
\item
3674+
if $o$ has scalar type, the value of $o$;
3675+
\item
3676+
otherwise, the constituent values of any direct subobjects of $o$
3677+
other than inactive union members.
3678+
\end{itemize}
3679+
The \defnx{constituent references}{constituent reference} of an object $o$ are
3680+
\begin{itemize}
3681+
\item
3682+
any direct members of $o$ that have reference type, and
3683+
\item
3684+
the constituent references of any direct subobjects of $o$
3685+
other than inactive union members.
3686+
\end{itemize}
3687+
36703688
\pnum
36713689
Some operations are described as
36723690
\defnx{implicitly creating objects}{object!implicit creation}

source/expressions.tex

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8291,31 +8291,13 @@
82918291
conditional-expression
82928292
\end{bnf}
82938293

8294-
\pnum
8295-
The \defnx{constituent values}{constituent value} of an object $o$ are
8296-
\begin{itemize}
8297-
\item
8298-
if $o$ has scalar type, the value of $o$;
8299-
\item
8300-
otherwise, the constituent values of any direct subobjects of $o$
8301-
other than inactive union members.
8302-
\end{itemize}
8303-
The \defnx{constituent references}{constituent reference} of an object $o$ are
8304-
\begin{itemize}
8305-
\item
8306-
any direct members of $o$ that have reference type, and
8307-
\item
8308-
the constituent references of any direct subobjects of $o$
8309-
other than inactive union members.
8310-
\end{itemize}
8311-
83128294
\pnum
83138295
The constituent values and constituent references of
83148296
a variable \tcode{x} are defined as follows:
83158297
\begin{itemize}
83168298
\item
83178299
If \tcode{x} declares an object,
8318-
the constituent values and references of that object are
8300+
the constituent values and references of that object\iref{intro.object} are
83198301
constituent values and references of \tcode{x}.
83208302
\item
83218303
If \tcode{x} declares a reference,

source/statements.tex

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1142,10 +1142,14 @@
11421142
\end{note}
11431143

11441144
\pnum
1145-
In a function whose return type is a reference,
1145+
In a function
11461146
other than an invented function for \tcode{std::is_convertible}\iref{meta.rel},
1147-
a \tcode{return} statement that binds the returned reference to
1148-
a temporary expression\iref{class.temporary} is ill-formed.
1147+
a \tcode{return} statement that binds
1148+
\begin{itemize}
1149+
\item a returned reference or
1150+
\item a constituent reference\iref{intro.object} of a returned object
1151+
\end{itemize}
1152+
to a temporary expression\iref{class.temporary} is ill-formed.
11491153
\begin{example}
11501154
\begin{codeblock}
11511155
auto&& f1() {

0 commit comments

Comments
 (0)