diff --git a/source/basic.tex b/source/basic.tex index e7d171d6fe..20d8970469 100644 --- a/source/basic.tex +++ b/source/basic.tex @@ -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}% @@ -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 @@ -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 @@ -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}. diff --git a/source/classes.tex b/source/classes.tex index c17568610b..39c538ecbd 100644 --- a/source/classes.tex +++ b/source/classes.tex @@ -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} @@ -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. @@ -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} @@ -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 @@ -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 { diff --git a/source/declarations.tex b/source/declarations.tex index fed6acc54f..aa28c9fcdd 100644 --- a/source/declarations.tex +++ b/source/declarations.tex @@ -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. @@ -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. @@ -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 @@ -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 { @@ -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. @@ -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 @@ -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} @@ -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, @@ -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} @@ -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} @@ -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} } diff --git a/source/exceptions.tex b/source/exceptions.tex index f7ce5ae44c..8dbd0304ef 100644 --- a/source/exceptions.tex +++ b/source/exceptions.tex @@ -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 diff --git a/source/expressions.tex b/source/expressions.tex index 3623d50012..c93a1bbb27 100644 --- a/source/expressions.tex +++ b/source/expressions.tex @@ -246,7 +246,7 @@ \pnum Whenever a glvalue appears as an operand of an operator that -expects a prvalue for that operand, the +requires a prvalue for that operand, the lvalue-to-rvalue\iref{conv.lval}, array-to-pointer\iref{conv.array}, or function-to-pointer\iref{conv.func} standard conversions are applied to convert the expression to a prvalue. @@ -518,7 +518,8 @@ conversions. \end{note} A standard conversion sequence will be applied to -an expression if necessary to convert it to a required destination type. +an expression if necessary to convert it to an expression having +a required destination type and value category. \pnum \begin{note} @@ -828,29 +829,22 @@ \rSec2[conv.prom]{Integral promotions} +\pnum +For the purposes of \ref{conv.prom}, +a \defnadj{converted}{bit-field} is a prvalue that is the result of +an lvalue-to-rvalue conversion\iref{conv.lval} applied to +a bit-field\iref{class.bit}. + \pnum \indextext{promotion!integral}% -A prvalue of an integer type other than \keyword{bool}, \keyword{char8_t}, \keyword{char16_t}, +A prvalue that is not a converted bit-field and has an integer type other than +\keyword{bool}, \keyword{char8_t}, \keyword{char16_t}, \keyword{char32_t}, or \keyword{wchar_t} whose integer conversion rank\iref{conv.rank} is less than the rank of \keyword{int} can be converted to a prvalue of type \keyword{int} if \keyword{int} can represent all the values of the source type; otherwise, the source prvalue can be converted to a prvalue of type \tcode{\keyword{unsigned} \keyword{int}}. -\pnum -\indextext{type!underlying!\idxcode{wchar_t}}% -\indextext{type!underlying!\idxcode{char16_t}}% -\indextext{type!underlying!\idxcode{char32_t}}% -A prvalue of type \keyword{char8_t}, \keyword{char16_t}, \keyword{char32_t}, or -\keyword{wchar_t}\iref{basic.fundamental} can be converted to a prvalue -of the first of the following types that can represent all the values of -its underlying type: \keyword{int}, \tcode{\keyword{unsigned} \keyword{int}}, \tcode{\keyword{long} \keyword{int}}, -\tcode{\keyword{unsigned} \keyword{long} \keyword{int}}, \tcode{\keyword{long} \keyword{long} \keyword{int}}, -or \tcode{\keyword{unsigned} \keyword{long} \keyword{long} \keyword{int}}. If none of the types in that list can -represent all the values of its underlying type, a prvalue of type -\keyword{char8_t}, \keyword{char16_t}, \keyword{char32_t}, or \keyword{wchar_t} can be converted -to a prvalue of its underlying type. - \pnum \indextext{type!underlying!enumeration}% A prvalue of an unscoped enumeration type whose underlying type is not @@ -870,15 +864,38 @@ if integral promotion can be applied to its underlying type, a prvalue of an unscoped enumeration type whose underlying type is fixed can also be converted to a prvalue of the promoted underlying type. +\begin{note} +A converted bit-field of enumeration type is treated as +any other value of that type for promotion purposes. +\end{note} \pnum -A prvalue for an integral bit-field\iref{class.bit} can be converted +A converted bit-field of integral type can be converted to a prvalue of type \keyword{int} if \keyword{int} can represent all the values of the bit-field; otherwise, it can be converted to \tcode{\keyword{unsigned} \keyword{int}} if \tcode{\keyword{unsigned} \keyword{int}} can represent all the -values of the bit-field. If the bit-field is larger yet, no integral -promotion applies to it. If the bit-field has enumeration type, it is -treated as any other value of that type for promotion purposes. +values of the bit-field. + +\pnum +\indextext{type!underlying!\idxcode{wchar_t}}% +\indextext{type!underlying!\idxcode{char16_t}}% +\indextext{type!underlying!\idxcode{char32_t}}% +A prvalue of type +\keyword{char8_t}, \keyword{char16_t}, \keyword{char32_t}, or +\keyword{wchar_t}\iref{basic.fundamental} +(including a converted bit-field that was not +already promoted to \keyword{int} or \tcode{\keyword{unsigned} \keyword{int}} +according to the rules above) +can be converted to a prvalue +of the first of the following types that can represent all the values of +its underlying type: +\keyword{int}, +\tcode{\keyword{unsigned} \keyword{int}}, +\tcode{\keyword{long} \keyword{int}}, +\tcode{\keyword{unsigned} \keyword{long} \keyword{int}}, +\tcode{\keyword{long} \keyword{long} \keyword{int}}, +\tcode{\keyword{unsigned} \keyword{long} \keyword{long} \keyword{int}}, or +its underlying type. \pnum \indextext{promotion!bool to int}% @@ -1051,7 +1068,10 @@ ambiguous\iref{class.member.lookup}, or virtual\iref{class.mi} base class of \tcode{D}, or a base class of a virtual base class of \tcode{D}, a program that necessitates this conversion is ill-formed. -The result of the conversion refers to the same member as the pointer to +If class \tcode{D} does not contain the original member and +is not a base class of the class containing the original member, +the behavior is undefined. Otherwise, +the result of the conversion refers to the same member as the pointer to member before the conversion took place, but it refers to the base class member as if it were a member of the derived class. The result refers to the member in \tcode{D}'s instance of \tcode{B}. Since the result has @@ -1117,6 +1137,10 @@ which are defined as follows: \begin{itemize} +\item The lvalue-to-rvalue conversion\iref{conv.lval} +is applied to each operand and +the resulting prvalues are used in place of the original operands +for the remainder of this section. \item If either operand is of scoped enumeration type\iref{dcl.enum}, no conversions are performed; if the other operand does not have the same type, the expression is ill-formed. @@ -1795,10 +1819,10 @@ \end{note} \pnum -If a \grammarterm{lambda-declarator} does not include -a \grammarterm{parameter-declaration-clause}, -it is as if \tcode{()} were inserted -at the start of the \grammarterm{lambda-declarator}. +A \grammarterm{lambda-expression}{'s} \grammarterm{parameter-declaration-clause} +is the \grammarterm{parameter-declaration-clause} of +the \grammarterm{lambda-expression}{'s} \grammarterm{lambda-declarator}, if any, +or empty otherwise. If the \grammarterm{lambda-declarator} does not include a \grammarterm{trailing-return-type}, it is considered to be \tcode{-> \keyword{auto}}. @@ -1845,7 +1869,8 @@ types of a \grammarterm{lambda-declarator} do not affect these associated namespaces and classes. \end{note} -The closure type is not an aggregate type\iref{dcl.init.aggr}. +The closure type is not an aggregate type\iref{dcl.init.aggr} and +not a structural type\iref{temp.param}. An implementation may define the closure type differently from what is described below provided this does not alter the observable behavior of the program other than by changing: @@ -1865,7 +1890,7 @@ inline function call operator (for a non-generic lambda) or function call operator template (for a generic lambda)\iref{over.call} whose parameters and return type -are described by the \grammarterm{lambda-expression}'s +are those of the \grammarterm{lambda-expression}{'s} \grammarterm{parameter-declaration-clause} and \grammarterm{trailing-return-type} respectively, and whose \grammarterm{template-parameter-list} consists of @@ -3166,10 +3191,10 @@ The postfix expression shall have function type or function pointer type. For a call to a non-member function or to a static member function, -the postfix expression shall either be an lvalue that refers to a +the postfix expression shall be either an lvalue that refers to a function (in which case the function-to-pointer standard conversion\iref{conv.func} is suppressed on the postfix expression), -or have function pointer type. +or a prvalue of function pointer type. \pnum If the selected @@ -3266,15 +3291,17 @@ lifetime of a parameter ends when the function in which it is defined returns or at the end of the enclosing full-expression. The initialization and destruction of each parameter occurs -within the context of the calling function. +within the context of the full-expression\iref{intro.execution} +where the function call appears. \begin{example} -The access of the constructor, conversion functions or destructor is -checked at the point of call in the calling function. If a constructor -or destructor for a function parameter throws an exception, the search -for a handler starts in the calling function; in -particular, if the function called has a \grammarterm{function-try-block}\iref{except.pre} -with a handler that can handle the exception, -this handler is not considered. +The access\iref{class.access.general} of the +constructor, conversion functions, or destructor is +checked at the point of call. If a constructor +or destructor for a function parameter throws an exception, +any \grammarterm{function-try-block}\iref{except.pre} +of the called function +with a handler that can handle the exception +is not considered. \end{example} \pnum @@ -3939,7 +3966,7 @@ \indextext{cast!reference}% An lvalue of type ``\cvqual{cv1} \tcode{B}'', where \tcode{B} is a class type, can be cast to type ``reference to \cvqual{cv2} \tcode{D}'', where -\tcode{D} is a class derived\iref{class.derived} from \tcode{B}, +\tcode{D} is a complete class derived\iref{class.derived} from \tcode{B}, if \cvqual{cv2} is the same cv-qualification as, or greater cv-qualification than, \cvqual{cv1}. If \tcode{B} is a virtual base class of \tcode{D} @@ -4139,7 +4166,7 @@ exists\iref{conv.mem}, the program is ill-formed. The null member pointer value\iref{conv.mem} is converted to the null member pointer value of the destination type. If class \tcode{B} -contains the original member, or is a base or derived class of the class +contains the original member, or is a base class of the class containing the original member, the resulting pointer to member points to the original member. Otherwise, the behavior is undefined. \begin{note} @@ -4608,14 +4635,16 @@ \pnum \indextext{operator!unary plus}% -The operand of the unary \tcode{+} operator shall have arithmetic, unscoped +The operand of the unary \tcode{+} operator shall be a prvalue of +arithmetic, unscoped enumeration, or pointer type and the result is the value of the argument. Integral promotion is performed on integral or enumeration operands. The type of the result is the type of the promoted operand. \pnum \indextext{operator!unary minus}% -The operand of the unary \tcode{-} operator shall have arithmetic or unscoped +The operand of the unary \tcode{-} operator shall be a prvalue of +arithmetic or unscoped enumeration type and the result is the negative of its operand. Integral promotion is performed on integral or enumeration operands. The negative of an unsigned quantity is computed by subtracting its value from $2^n$, @@ -4636,7 +4665,8 @@ \pnum \indextext{operator!ones' complement}% -The operand of the \tcode{\~{}} operator shall have integral or unscoped enumeration type. +The operand of the \tcode{\~{}} operator shall be a prvalue of +integral or unscoped enumeration type. Integral promotions are performed. The type of the result is the type of the promoted operand. % FIXME: [basic.fundamental]/p5 uses $x_i$; [expr] uses $\tcode{x}_i$. @@ -5031,8 +5061,11 @@ \end{note} \pnum +If the operand is a prvalue, +the temporary materialization conversion\iref{conv.rval} is applied. The result of the \keyword{noexcept} operator is \keyword{true} -unless the \grammarterm{expression} is potentially-throwing\iref{except.spec}. +unless the full-expression of the operand +is potentially-throwing\iref{except.spec}. \indextext{expression!unary|)} \rSec3[expr.new]{New} @@ -5047,7 +5080,7 @@ \indextext{storage management|see{\tcode{delete}}}% \indextext{\idxcode{new}}% The \grammarterm{new-expression} attempts to create an object of the -\grammarterm{type-id}\iref{dcl.name} or \grammarterm{new-type-id} to which +\grammarterm{type-id} or \grammarterm{new-type-id}\iref{dcl.name} to which it is applied. The type of that object is the \defnadj{allocated}{type}. \indextext{type!incomplete}% This type shall be a complete object type\iref{term.incomplete.type}, @@ -5508,7 +5541,8 @@ \begin{note} When the allocation function returns a value other than null, it must be a pointer to a block of storage in which space for the object has been -reserved. The block of storage is assumed to be appropriately aligned +reserved. The block of storage is assumed to be +appropriately aligned\iref{basic.align} and of the requested size. The address of the created object will not necessarily be the same as that of the block if the object is an array. \end{note} @@ -5652,8 +5686,8 @@ that consists of empty square brackets can follow the \keyword{delete} keyword if the \grammarterm{lambda-expression} is enclosed in parentheses. \end{footnote} -The operand shall be of pointer to object type or of class type. If of -class type, the operand is contextually implicitly converted\iref{conv} +If the operand is of +class type, it is contextually implicitly converted\iref{conv} to a pointer to object type. \begin{footnote} @@ -5661,6 +5695,7 @@ cannot be deleted using a pointer of type \tcode{\keyword{void}*} because \keyword{void} is not an object type. \end{footnote} +Otherwise, it shall be a prvalue of pointer to object type. The \grammarterm{delete-expression} has type \keyword{void}. @@ -6017,6 +6052,7 @@ \pnum The binary operator \tcode{.*} binds its second operand, which shall be +a prvalue of type ``pointer to member of \tcode{T}'' to its first operand, which shall be a glvalue of @@ -6026,6 +6062,7 @@ \pnum The binary operator \tcode{->*} binds its second operand, which shall be +a prvalue of type ``pointer to member of \tcode{T}'' to its first operand, which shall be of type ``pointer to \tcode{U}'' where \tcode{U} is either \tcode{T} or @@ -6149,9 +6186,14 @@ \indextext{operator!additive} \pnum -The additive operators \tcode{+} and \tcode{-} group left-to-right. The -usual arithmetic conversions\iref{expr.arith.conv} are performed for operands of arithmetic or -enumeration type. +The additive operators \tcode{+} and \tcode{-} group left-to-right. +Each operand shall be a prvalue. +If both operands have arithmetic or unscoped enumeration type, +the usual arithmetic conversions\iref{expr.arith.conv} are performed. +Otherwise, if one operand has arithmetic or unscoped enumeration type, +integral promotion is applied\iref{conv.prom} to that operand. +A converted or promoted operand is used in place of +the corresponding original operand for the remainder of this section. \indextext{operator!addition}% \indextext{addition operator|see{operator, addition}}% @@ -6168,14 +6210,14 @@ \end{bnf} \indextext{incomplete}% -For addition, either both operands shall have arithmetic or unscoped enumeration +For addition, either both operands shall have arithmetic type, or one operand shall be a pointer to a completely-defined object -type and the other shall have integral or unscoped enumeration type. +type and the other shall have integral type. \pnum For subtraction, one of the following shall hold: \begin{itemize} -\item both operands have arithmetic or unscoped enumeration type; or +\item both operands have arithmetic type; or \item \indextext{arithmetic!pointer}% @@ -6183,7 +6225,7 @@ versions of the same completely-defined object type; or \item the left operand is a pointer to a completely-defined object type -and the right operand has integral or unscoped enumeration type. +and the right operand has integral type. \end{itemize} \pnum @@ -6286,7 +6328,7 @@ shift-expression \terminal{>>} additive-expression \end{bnf} -The operands shall be of integral or unscoped enumeration type and integral +The operands shall be prvalues of integral or unscoped enumeration type and integral promotions are performed. The type of the result is that of the promoted left operand. \indextext{left shift!undefined}% @@ -6303,7 +6345,8 @@ \end{note} \pnum -The value of \tcode{E1 >> E2} is $\tcode{E1} / 2^\tcode{E2}$, rounded down. +The value of \tcode{E1 >> E2} is $\tcode{E1} / 2^\tcode{E2}$, +rounded towards negative infinity. \begin{note} \tcode{E1} is right-shifted \tcode{E2} bit positions. Right-shift on signed integral types is an arithmetic right shift, @@ -7046,19 +7089,26 @@ A \grammarterm{throw-expression} is of type \keyword{void}. \pnum -Evaluating a \grammarterm{throw-expression} with an operand throws an -exception\iref{except.throw}; the type of the exception object is determined by removing -any top-level \grammarterm{cv-qualifier}{s} from the static type of the -operand and adjusting the type -from ``array of \tcode{T}'' or function type \tcode{T} -to ``pointer to \tcode{T}''. +A \grammarterm{throw-expression} with an operand throws an +exception\iref{except.throw}. +The array-to-pointer\iref{conv.array} and function-to-pointer\iref{conv.func} +standard conversions are performed on the operand. +The type of the exception object is determined by removing +any top-level \grammarterm{cv-qualifier}{s} from the type of the +(possibly converted) operand. +The exception object is copy-initialized\iref{dcl.init.general} +from the (possibly converted) operand. \pnum \indextext{exception handling!rethrow}% A \grammarterm{throw-expression} with no operand rethrows the currently handled exception\iref{except.handle}. -The exception is reactivated with the existing exception object; +\indextext{exception handling!terminate called@\tcode{terminate} called}% +\indextext{\idxcode{terminate}!called}% +If no exception is presently being handled, +the function \tcode{std::terminate} is invoked\iref{except.terminate}. +Otherwise, the exception is reactivated with the existing exception object; no new exception object is created. The exception is no longer considered to be caught. \begin{example} @@ -7074,16 +7124,6 @@ \end{codeblock} \end{example} -\pnum -\indextext{exception handling!rethrow}% -\indextext{exception handling!terminate called@\tcode{terminate} called}% -\indextext{\idxcode{terminate}!called}% -If no exception is presently being handled, -evaluating a -\grammarterm{throw-expression} -with no operand calls -\tcode{std::\brk{}terminate()}\iref{except.terminate}. - \rSec2[expr.ass]{Assignment and compound assignment operators}% \indextext{expression!assignment and compound assignment} @@ -7337,7 +7377,7 @@ \item a control flow that passes through -a declaration of a variable with +a declaration of a block variable\iref{basic.scope.block} with static\iref{basic.stc.static} or thread\iref{basic.stc.thread} storage duration, unless that variable is usable in constant expressions; @@ -7522,6 +7562,12 @@ \item a \keyword{goto} statement\iref{stmt.goto}. +\begin{note} +A \keyword{goto} statement introduced by equivalence\iref{stmt.stmt} +is not in scope. +For example, a \keyword{while} statement\iref{stmt.while} +can be executed during constant evaluation. +\end{note} \end{itemize} It is unspecified whether $E$ is a core constant expression @@ -7596,7 +7642,7 @@ \tcode{std::construct_at} or \tcode{std::ranges::construct_at} is considered to include only -the underlying constructor call +the initialization of the \tcode{T} object if the first argument (of type \tcode{T*}) points to storage allocated with \tcode{std::allocator} or to an object whose lifetime began within the evaluation of $E$. diff --git a/source/lex.tex b/source/lex.tex index a253a50bae..a26a086d5c 100644 --- a/source/lex.tex +++ b/source/lex.tex @@ -1317,21 +1317,27 @@ \end{floattable} \pnum -If an \grammarterm{integer-literal} +Except for \grammarterm{integer-literal}{s} containing +a \grammarterm{size-suffix}, +if the value of an \grammarterm{integer-literal} cannot be represented by any type in its list and an extended integer type\iref{basic.fundamental} can represent its value, it may have that extended integer type. If all of the types in the list for the \grammarterm{integer-literal} are signed, -the extended integer type shall be signed. +the extended integer type is signed. If all of the types in the list for the \grammarterm{integer-literal} are unsigned, -the extended integer type shall be unsigned. +the extended integer type is unsigned. If the list contains both signed and unsigned types, the extended integer type may be signed or unsigned. -A program is ill-formed -if one of its translation units contains an \grammarterm{integer-literal} -that cannot be represented by any of the allowed types. +If an \grammarterm{integer-literal} +cannot be represented by any of the allowed types, +the program is ill-formed. +\begin{note} +An \grammarterm{integer-literal} with a \tcode{z} or \tcode{Z} suffix +is ill-formed if it cannot be represented by \tcode{std::size_t}. +\end{note} \rSec2[lex.ccon]{Character literals} diff --git a/source/modules.tex b/source/modules.tex index 78825dd401..3d299b553c 100644 --- a/source/modules.tex +++ b/source/modules.tex @@ -448,6 +448,8 @@ to the source file or header nominated by \tcode{H}, which shall not contain a \grammarterm{module-declaration}. \begin{note} +A header unit is a separate translation unit with +an independent set of defined macros. All declarations within a header unit are implicitly exported\iref{module.interface}, and are attached to the global module\iref{module.unit}. diff --git a/source/overloading.tex b/source/overloading.tex index d0698b19ea..edf9542eaa 100644 --- a/source/overloading.tex +++ b/source/overloading.tex @@ -833,15 +833,8 @@ \end{example} \pnum -For the built-in assignment operators, conversions of the left -operand are restricted as follows: -\begin{itemize} -\item -no temporaries are introduced to hold the left operand, and -\item -no user-defined conversions are applied to the left operand to achieve -a type match with the left-most parameter of a built-in candidate. -\end{itemize} +For the first parameter of the built-in assignment operators, +only standard conversion sequences\iref{over.ics.scs} are considered. \pnum For all other operators, no such restrictions apply. @@ -2363,7 +2356,8 @@ expression and special rules apply for converting it to a parameter type. \pnum -If the initializer list is a \grammarterm{designated-initializer-list}, +If the initializer list is a \grammarterm{designated-initializer-list} +and the parameter is not a reference, a conversion is only possible if the parameter has an aggregate type that can be initialized from the initializer list diff --git a/source/templates.tex b/source/templates.tex index edac0e2650..67600f17e5 100644 --- a/source/templates.tex +++ b/source/templates.tex @@ -2413,7 +2413,10 @@ The same restrictions apply to the \grammarterm{parameter-declaration-clause} of a deduction guide -as in a function declaration\iref{dcl.fct}. +as in a function declaration\iref{dcl.fct}, +except that a generic parameter type placeholder\iref{dcl.spec.auto} +shall not appear in the \grammarterm{parameter-declaration-clause} of +a deduction guide. The \grammarterm{simple-template-id} shall name a class template specialization. The \grammarterm{template-name} @@ -2842,6 +2845,10 @@ The instantiation of a \tcode{sizeof...} expression\iref{expr.sizeof} produces an integral constant with value $N$. +\pnum +The instantiation of an \grammarterm{alignment-specifier} with an ellipsis +produces $\tcode{E}_1$ $\tcode{E}_2$ $\dotsc$ $\tcode{E}_N$. + \pnum The instantiation of a \grammarterm{fold-expression}\iref{expr.prim.fold} produces: \begin{itemize} @@ -4436,7 +4443,7 @@ \pnum \indextext{checking!syntax}% \indextext{checking!point of error}% -The validity of a template may be checked prior to any instantiation. +The validity of a templated entity may be checked prior to any instantiation. \begin{note} Knowing which names are type names allows the syntax of every template to be checked in this way. @@ -4445,10 +4452,14 @@ \begin{itemize} \item no valid specialization, -ignoring \grammarterm{static_assert-declaration}{s} that fail, -can be generated for a template -or a substatement of a constexpr if statement\iref{stmt.if} within a template -and the template is not instantiated, or +ignoring \grammarterm{static_assert-declaration}{s} that fail\iref{dcl.pre}, +can be generated for a templated entity +or a substatement of a constexpr if statement\iref{stmt.if} +within a templated entity +and the innermost enclosing template is not instantiated, or +\item +no specialization of an alias template\iref{temp.alias} is valid and +no specialization of the alias template is named in the program, or \item any \grammarterm{constraint-expression} in the program, introduced or otherwise, has (in its normal form) an atomic constraint $A$ where @@ -4458,16 +4469,18 @@ every valid specialization of a variadic template requires an empty template parameter pack, or \item -a hypothetical instantiation of a template +a hypothetical instantiation of a templated entity immediately following its definition would be ill-formed -due to a construct that does not depend on a template parameter, or +due to a construct +(other than a \grammarterm{static_assert-declaration} that fails) +that does not depend on a template parameter, or \item the interpretation of such a construct in the hypothetical instantiation is different from the interpretation of the corresponding construct -in any actual instantiation of the template. +in any actual instantiation of the templated entity. \end{itemize} \begin{note} This can happen in situations including the following: