Skip to content

[Motions 2023 06 cwg 1] P2922R0 Core Language Working Group "ready" Issues #6328

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 32 commits into from
Jul 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
23712f5
CWG170 Pointer-to-member conversions
burblebee Jun 21, 2023
edfbb70
CWG1353 Array and variant members and deleted special member functions
burblebee Jun 21, 2023
9edd682
CWG1642 Missing requirements for prvalue operands
burblebee Jun 21, 2023
9e751a8
CWG1973 Which parameter-declaration-clause in a lambda-expression?
burblebee Jun 21, 2023
3c75a4e
CWG2485 Bit-fields in integral promotions
burblebee Jun 21, 2023
3d711d3
CWG2519 Object representation of a bit-field
burblebee Jun 21, 2023
b42c704
CWG2542 Is a closure type a structural type?
burblebee Jun 21, 2023
11ffdbf
CWG2550 Type "reference to cv void" outside of a declarator
burblebee Jun 21, 2023
d369c12
CWG2552 Constant evaluation of non-defining variable declarations
burblebee Jun 21, 2023
a661eca
CWG2663 Example for member redeclarations with using-declarations
burblebee Jun 21, 2023
a282091
CWG2683 Default arguments for member functions of templated nested cl…
burblebee Jun 21, 2023
7f17f18
CWG2697 Deduction guides using abbreviated function syntax
burblebee Jun 21, 2023
13355ba
CWG2698 Using extended integer types with z suffix
burblebee Jun 21, 2023
3588b7d
CWG2699 Inconsistency of throw-expression specification
burblebee Jun 21, 2023
f4bb205
CWG2708 Parenthesized initialization of arrays
burblebee Jun 21, 2023
e495b95
CWG2710 Loops in constant expressions
burblebee Jun 21, 2023
19f42f6
CWG2711 Source for copy-initializing the exception object
burblebee Jun 21, 2023
b3b0a0b
CWG2712 Simplify restrictions on built-in assignment operator candidates
burblebee Jun 21, 2023
a75c7bf
CWG2713 Initialization of reference-to-aggregate from designated init…
burblebee Jun 21, 2023
5b59344
CWG2715 "calling function" for parameter initialization may not exist
burblebee Jun 21, 2023
be6d0b1
CWG2716 Rule about self-or-base conversion is normatively redundant
burblebee Jun 21, 2023
4bcdf37
CWG2717 Pack expansion for alignment-specifier
burblebee Jun 21, 2023
8758d3a
CWG2718 Type completeness for derived-to-base conversions
burblebee Jun 21, 2023
3f3043a
CWG2719 Creating objects in misaligned storage
burblebee Jun 21, 2023
a8d1e30
CWG2720 Template validity rules for templated entities and alias temp…
burblebee Jun 21, 2023
8d14bef
CWG2721 When exactly is storage reused?
burblebee Jun 21, 2023
8970cb2
CWG2722 Temporary materialization conversion for noexcept operator
burblebee Jun 21, 2023
a118063
CWG2723 Range of representable values for floating-point types
burblebee Jun 21, 2023
bf368c6
CWG2724 Clarify rounding for arithmetic right shift
burblebee Jun 21, 2023
42b2651
CWG2729 Meaning of new-type-id
burblebee Jun 21, 2023
065834a
CWG2732 Can importable headers react to preprocessor state from point…
burblebee Jun 21, 2023
f1e4e9e
CWG2750 construct_at without constructor call
burblebee Jun 21, 2023
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
55 changes: 51 additions & 4 deletions source/basic.tex
Original file line number Diff line number Diff line change
Expand Up @@ -3384,6 +3384,21 @@
\item the storage which the object occupies is released,
or is reused by an object that is not nested within \placeholder{o}\iref{intro.object}.
\end{itemize}
When evaluating a \grammarterm{new-expression},
storage is considered reused after it is returned from the allocation function,
but before the evaluation of the \grammarterm{new-initializer}\iref{expr.new}.
\begin{example}
\begin{codeblock}
struct S {
int m;
};

void f() {
S x{1};
new(&x) S(x.m); // undefined behavior
}
\end{codeblock}
\end{example}

\pnum
\indextext{reference lifetime}%
Expand Down Expand Up @@ -4103,6 +4118,9 @@
at which a given object can be allocated. An object type imposes an alignment
requirement on every object of that type; stricter alignment can be requested
using the alignment specifier\iref{dcl.align}.
Attempting to create an object\iref{intro.object} in storage that
does not meet the alignment requirements of the object's type
is undefined behavior.

\pnum
A \defnadj{fundamental}{alignment} is represented by an alignment
Expand Down Expand Up @@ -4637,15 +4655,28 @@
\pnum
\label{term.object.representation}%
The \defnx{object representation}{representation!object}
of an object of type \tcode{T} is the
of a complete object type \tcode{T} is the
sequence of \placeholder{N} \tcode{\keyword{unsigned} \keyword{char}} objects taken up
by the object of type \tcode{T}, where \placeholder{N} equals
by a non-bit-field complete object of type \tcode{T},
where \placeholder{N} equals
\tcode{\keyword{sizeof}(T)}.
The \defnx{value representation}{representation!value}
of an object of type \tcode{T} is the set of bits
of a type \tcode{T} is the set of bits
in the object representation of \tcode{T}
that participate in representing a value of type \tcode{T}.
The object and value representation of
a non-bit-field complete object of type \tcode{T} are
the bytes and bits, respectively, of
the object corresponding to the object and value representation of its type.
The object representation of a bit-field object is
the sequence of \placeholder{N} bits taken up by the object,
where \placeholder{N} is the width of the bit-field\iref{class.bit}.
The value representation of a bit-field object is
the set of bits in the object representation that
participate in representing its value.
\label{term.padding.bits}%
Bits in the object representation that are not part of the value representation
Bits in the object representation of a type or object that are
not part of the value representation
are \defn{padding bits}.
For trivially copyable types, the value representation is
a set of bits in the object representation that determines a
Expand Down Expand Up @@ -5058,6 +5089,22 @@
the object and value representations and accuracy of operations
of floating-point types are \impldef{representation of floating-point types}.

\pnum
The minimum range of representable values for a floating-point type is
the most negative finite floating-point number representable
in that type through
the most positive finite floating-point number representable in that type.
In addition, if negative infinity is representable in a type,
the range of that type is extended to all negative real numbers;
likewise, if positive infinity is representable in a type,
the range of that type is extended to all positive real numbers.
\begin{note}
Since negative and positive infinity are representable
in ISO/IEC/IEEE 60559 formats,
all real numbers lie within the range of representable values of
a floating-point type adhering to ISO/IEC/IEEE 60559.
\end{note}

\pnum
Integral and floating-point types are collectively
termed \defnx{arithmetic types}{type!arithmetic}.
Expand Down
97 changes: 43 additions & 54 deletions source/classes.tex
Original file line number Diff line number Diff line change
Expand Up @@ -1247,38 +1247,34 @@
\pnum
A defaulted default constructor for class \tcode{X} is defined as deleted if:
\begin{itemize}
\item \tcode{X} is a union that has a variant member
with a non-trivial default constructor and
no variant member of \tcode{X} has a default member initializer,

\item \tcode{X} is a non-union class that has a variant member \tcode{M}
with a non-trivial default constructor and
no variant member of the anonymous union containing \tcode{M}
has a default member initializer,

\item any non-static data member with no default member initializer\iref{class.mem} is
of reference type,

\item any non-variant non-static data member of const-qualified type (or array
thereof) with no \grammarterm{brace-or-equal-initializer}
\item any non-variant non-static data member of const-qualified type
(or possibly multi-dimensional array thereof)
with no \grammarterm{brace-or-equal-initializer}
is not const-default-constructible\iref{dcl.init},

\item \tcode{X} is a union and all of its variant members are of const-qualified
type (or array thereof),
type (or possibly multi-dimensional array thereof),

\item \tcode{X} is a non-union class and all members of any anonymous union member are
of const-qualified type (or array thereof),
of const-qualified type (or possibly multi-dimensional array thereof),

\item any potentially constructed subobject, except for a non-static data member
with a \grammarterm{brace-or-equal-initializer}, has
class type \tcode{M} (or array thereof) and either \tcode{M}
has no default constructor or overload resolution\iref{over.match}
as applied to find \tcode{M}'s corresponding
constructor results in an ambiguity or in a function that is deleted or
inaccessible from the defaulted default constructor, or

\item any potentially constructed subobject has a type
with a destructor that is deleted or inaccessible from the defaulted default
with a \grammarterm{brace-or-equal-initializer}
or a variant member of a union where another non-static data member
has a \grammarterm{brace-or-equal-initializer},
has class type \tcode{M} (or possibly multi-dimensional array thereof)
and overload resolution\iref{over.match}
as applied to find \tcode{M}'s corresponding constructor
either does not result in a usable candidate\iref{over.match.general}
or, in the case of a variant member, selects a non-trivial function, or

\item any potentially constructed subobject has
class type \tcode{M} (or possibly multi-dimensional array thereof) and
\tcode{M} has
a destructor that is deleted or inaccessible from the defaulted default
constructor.
\end{itemize}

Expand Down Expand Up @@ -1543,18 +1539,16 @@
\tcode{X} is defined as deleted\iref{dcl.fct.def.delete} if \tcode{X} has:
\begin{itemize}
\item a potentially constructed subobject of type
\tcode{M} (or array thereof) that cannot be copied/moved because
\tcode{M} (or possibly multi-dimensional array thereof) for which
overload resolution\iref{over.match}, as applied to find
\tcode{M}'s
corresponding constructor, results in an ambiguity or
a function that is deleted or inaccessible from the
defaulted constructor,

\item a variant member whose corresponding constructor
as selected by overload resolution is non-trivial,

\item any potentially constructed subobject of a type
with a destructor that is deleted or inaccessible from the defaulted
\tcode{M}'s corresponding constructor,
either does not result in a usable candidate\iref{over.match.general} or,
in the case of a variant member, selects a non-trivial function,

\item any potentially constructed subobject of
class type \tcode{M} (or possibly multi-dimensional array thereof)
where \tcode{M} has
a destructor that is deleted or inaccessible from the defaulted
constructor, or,

\item for the copy constructor, a non-static data member of rvalue reference type.
Expand Down Expand Up @@ -1823,21 +1817,19 @@
A defaulted copy/move assignment operator for
class \tcode{X} is defined as deleted if \tcode{X} has:
\begin{itemize}
\item a variant member with a non-trivial corresponding assignment operator and
\tcode{X} is a union-like class, or

\item a non-static data member of \keyword{const} non-class
type (or array thereof), or
type (or possibly multi-dimensional array thereof), or

\item a non-static data member of reference type, or

\item a direct non-static data member of class type \tcode{M}
(or array thereof) or a direct base class \tcode{M}
(or possibly multi-dimensional array thereof) or
a direct base class \tcode{M}
that cannot be copied/moved because overload resolution
\iref{over.match}, as applied to find \tcode{M}'s corresponding
assignment operator, results in an ambiguity or
a function that is deleted or inaccessible from the
defaulted assignment operator.
assignment operator,
either does not result in a usable candidate\iref{over.match.general} or,
in the case of a variant member, selects a non-trivial function.
\end{itemize}

\begin{note}
Expand Down Expand Up @@ -2070,13 +2062,11 @@
A defaulted destructor for a class
\tcode{X} is defined as deleted if:
\begin{itemize}
\item \tcode{X} is a union-like class that has a variant
member with a non-trivial destructor,

\item any potentially constructed subobject has class type
\tcode{M} (or array thereof) and
\tcode{M} has a deleted destructor or a destructor
that is inaccessible from the defaulted destructor,
\tcode{M} (or possibly multi-dimensional array thereof) and
\tcode{M} has a destructor that is deleted or
is inaccessible from the defaulted destructor or,
in the case of a variant member, is non-trivial,

\item or, for a virtual destructor, lookup of the non-array deallocation
function results in an ambiguity or in a function that is deleted or
Expand Down Expand Up @@ -2489,17 +2479,16 @@
returning \grammarterm{conversion-type-id}''.

\pnum
A conversion function is never used to convert a (possibly cv-qualified) object
to the (possibly cv-qualified) same object type (or a reference to it),
to a (possibly cv-qualified) base class of that type (or a reference to it),
\begin{note}
A conversion function is never invoked for
implicit or explicit conversions of an object
to the same object type (or a reference to it),
to a base class of that type (or a reference to it),
or to \cv{}~\keyword{void}.
\begin{footnote}
These conversions are considered
as standard conversions for the purposes of overload resolution\iref{over.best.ics,over.ics.ref} and therefore initialization\iref{dcl.init} and explicit casts\iref{expr.static.cast}. A conversion to \keyword{void} does not invoke any conversion function\iref{expr.static.cast}.
Even though never directly called to perform a conversion,
such conversion functions can be declared and can potentially
be reached through a call to a virtual conversion function in a base class.
\end{footnote}
\end{note}
\begin{example}
\begin{codeblock}
struct X {
Expand Down
44 changes: 34 additions & 10 deletions source/declarations.tex
Original file line number Diff line number Diff line change
Expand Up @@ -2272,7 +2272,7 @@
\tcode{typeid},
the name of a type shall be specified.
This can be done with a
\grammarterm{type-id},
\grammarterm{type-id} or \grammarterm{new-type-id}\iref{expr.new},
which is syntactically a declaration for a variable or function
of that type that omits the name of the entity.

Expand Down Expand Up @@ -2859,7 +2859,7 @@
A reference can be thought of as a name of an object.
\end{note}
\indextext{\idxcode{void\&}}%
A declarator that specifies the type
Forming the type
``reference to \cv{}~\keyword{void}''
is ill-formed.

Expand Down Expand Up @@ -4075,7 +4075,7 @@
\end{note}

\pnum
Except for member functions of class templates, the
Except for member functions of templated classes, the
default arguments in a member function definition that appears
outside of the class definition
are added to the set of default arguments provided by the
Expand All @@ -4084,9 +4084,9 @@
copy or move constructor\iref{class.copy.ctor}, or
copy or move assignment operator\iref{class.copy.assign}
is so declared.
Default arguments for a member function of a class template
Default arguments for a member function of a templated class
shall be specified on the initial declaration of the member
function within the class template.
function within the templated class.
\begin{example}
\begin{codeblock}
class C {
Expand Down Expand Up @@ -4489,7 +4489,7 @@
If no initializer is specified for an object, the object is default-initialized.

\pnum
If the entity being initialized does not have class type, the
If the entity being initialized does not have class or array type, the
\grammarterm{expression-list} in a
parenthesized initializer shall be a single expression.

Expand Down Expand Up @@ -4696,8 +4696,9 @@
\item
Otherwise, the initial value of the object being initialized is
the (possibly converted) value of the initializer expression.
A standard conversion sequence\iref{conv} will be used, if necessary,
to convert the initializer expression to the cv-unqualified version of
A standard conversion sequence\iref{conv} is used
to convert the initializer expression to
a prvalue of the cv-unqualified version of
the destination type;
no user-defined conversions are considered.
If the conversion cannot
Expand Down Expand Up @@ -5738,7 +5739,8 @@
\begin{itemize}
\item
If the \grammarterm{braced-init-list}
contains a \grammarterm{designated-initializer-list},
contains a \grammarterm{designated-initializer-list} and
\tcode{T} is not a reference type,
\tcode{T} shall be an aggregate class.
The ordered \grammarterm{identifier}{s}
in the \grammarterm{designator}{s}
Expand Down Expand Up @@ -5862,7 +5864,9 @@
\end{example}

\item Otherwise, if
the initializer list has a single element of type \tcode{E} and either
the initializer list
is not a \grammarterm{designated-initializer-list} and
has a single element of type \tcode{E} and either
\tcode{T} is not a reference type or its referenced type is
reference-related to \tcode{E}, the object or reference is initialized
from that element (by copy-initialization for copy-list-initialization,
Expand Down Expand Up @@ -5907,6 +5911,9 @@
struct A { } a;
struct B { explicit B(const A&); };
const B& b2{a}; // error: cannot copy-list-initialize \tcode{B} temporary from \tcode{A}

struct C { int x; };
C&& c = { .x = 1 }; // OK
\end{codeblock}
\end{example}

Expand Down Expand Up @@ -7902,6 +7909,22 @@
\pnum
If a declaration is named by two \grammarterm{using-declarator}s
that inhabit the same class scope, the program is ill-formed.
\begin{example}
\begin{codeblock}
struct C {
int i;
};

struct D1 : C { };
struct D2 : C { };

struct D3 : D1, D2 {
using D1::i; // OK, equivalent to \tcode{using C::i}
using D1::i; // error: duplicate
using D2::i; // error: duplicate, also names \tcode{C::i}
};
\end{codeblock}
\end{example}

\pnum
\begin{note}
Expand Down Expand Up @@ -7984,6 +8007,7 @@
using A::h; // error: conflicts
using B::x;
using A::x; // OK, hides \tcode{struct B::x}
using A::x; // OK, does not conflict with previous \tcode{using A::x}
x = 99; // assigns to \tcode{A::x}
struct x x1; // \tcode{x1} has class type \tcode{B::x}
}
Expand Down
7 changes: 4 additions & 3 deletions source/exceptions.tex
Original file line number Diff line number Diff line change
Expand Up @@ -257,13 +257,14 @@

\pnum
Throwing an exception
copy-initializes\iref{dcl.init,class.copy.ctor} a temporary object,
initializes a temporary object,
called the
\defnx{exception object}{exception handling!exception object}.
If the type of the exception object would be
an incomplete type,
an incomplete type\iref{basic.types.general},
an abstract class type\iref{class.abstract},
or a pointer to an incomplete type other than \cv{}~\keyword{void}
or a pointer to an incomplete type other than
\cv{}~\keyword{void}\iref{basic.compound}
the program is ill-formed.

\pnum
Expand Down
Loading