diff --git a/source/basic.tex b/source/basic.tex index 2f9a6abdc8..f3a2ef1a51 100644 --- a/source/basic.tex +++ b/source/basic.tex @@ -74,8 +74,7 @@ \grammarterm{identifier} in a structured binding declaration\iref{dcl.struct.bind}, \item -\grammarterm{identifier} -in a \grammarterm{result-name-introducer} +\grammarterm{result-name-introducer} in a postcondition assertion\iref{dcl.contract.res}, \item \grammarterm{init-capture}\iref{expr.prim.lambda.capture}, @@ -126,16 +125,17 @@ \end{note} \pnum -A \defn{variable} is introduced by the -declaration $D$ of +A \defn{variable} is introduced by an object declaration\iref{dcl.pre} that \begin{itemize} \item -a reference other than a non-static data member or +is not the \grammarterm{parameter-declaration} of +a \grammarterm{template-parameter} and \item -an object, +does not declare a non-static member\iref{class.mem.general}. \end{itemize} -where $D$ is not the \grammarterm{parameter-declaration} of -a \grammarterm{template-parameter}. +\begin{note} +An object declaration can declare an object or a reference. +\end{note} \pnum An \defn{entity} is a @@ -623,8 +623,16 @@ a \grammarterm{lambda-expression} that has a \grammarterm{simple-capture} naming the entity or has a \grammarterm{capture-default}, and -the block scope of the \grammarterm{lambda-expression} -is also an intervening scope. +at least one of the following is also an intervening scope: + \begin{itemize} + \item + the block scope of the \grammarterm{lambda-expression}, or + \item + a contract-assertion scope\iref{basic.scope.contract} + introduced by a function contract assertion\iref{dcl.contract.func} of + the function call operator or operator template + of the corresponding closure type. + \end{itemize} \end{itemize} \end{itemize} @@ -826,10 +834,13 @@ that are not value-dependent shall have the same value\iref{expr.const,temp.dep.constexpr}. -\item In each such definition, the overloaded operators referred -to, the implicit calls to conversion functions, constructors, operator -new functions and operator delete functions, shall refer to the same -function. +%%FIXME: Hard to parse, should all be preceded by "the"? Or none? +\item In each such definition, +the operators referred to, +the implicit calls to conversion functions, +constructors, and +allocation and deallocation functions +shall refer to the same function, if any. \item In each such definition, a default argument used by an (implicit or explicit) function call or @@ -3067,10 +3078,21 @@ Two declarations of entities declare the same entity if, considering declarations of unnamed types to introduce their names for linkage purposes, if any\iref{dcl.typedef,dcl.enum}, +\begin{itemize} +\item they correspond\iref{basic.scope.scope}, -have the same target scope that is not a function or template parameter scope, +\item +both have the same target scope that +is not a function or template parameter scope, +\item neither is a name-independent declaration, -and either +\item +if either declares a type alias, both do, +\item +if either declares a namespace alias, both do, and + +\item +one of the following holds: \begin{itemize} \item they appear in the same translation unit, or @@ -3079,6 +3101,7 @@ \item they both declare names with module or external linkage and are attached to the same module. \end{itemize} +\end{itemize} \begin{note} There are other circumstances in which declarations declare the same entity\iref{dcl.link,temp.type,temp.spec.partial}. @@ -4030,6 +4053,7 @@ well-defined. Indirection through such a pointer is permitted but the resulting lvalue may only be used in limited ways, as described below. The program has undefined behavior if: +%%FIXME: The 1st item should end with "or". \begin{itemize} \item the pointer is used as the operand of a \grammarterm{delete-expression}\ubdef{lifetime.outside.pointer.delete}, @@ -4038,8 +4062,7 @@ non-static member function of the object\ubdef{lifetime.outside.pointer.member}, or \item the pointer is converted\iref{conv.ptr,expr.static.cast} to a pointer - to a virtual base class\ubdef{lifetime.outside.pointer.virtual} or - to a base class thereof, or + to a transitively virtual base class\iref{class.mi}\ubdef{lifetime.outside.pointer.virtual}, or \item the pointer is used as the operand of a \keyword{dynamic_cast}\iref{expr.dynamic.cast}\ubdef{lifetime.outside.pointer.dynamic.cast}. @@ -4089,7 +4112,8 @@ \begin{itemize} \item the glvalue is used to access the object\ubdef{lifetime.outside.glvalue.access}, or \item the glvalue is used to call a non-static member function of the object\ubdef{lifetime.outside.glvalue.member}, or -\item the glvalue is bound to a reference to a virtual base class\iref{dcl.init.ref}\ubdef{lifetime.outside.glvalue.virtual}, or +\item the glvalue is bound to a reference to + a transitively virtual base class\iref{dcl.init.ref,class.mi}\ubdef{lifetime.outside.glvalue.virtual}, or \item the glvalue is used as the operand of a \keyword{dynamic_cast}\iref{expr.dynamic.cast} or as the operand of \keyword{typeid}\ubdef{lifetime.outside.glvalue.dynamic.cast}. @@ -4673,7 +4697,7 @@ \pnum \indextext{\idxcode{delete}!overloading and}% -Each deallocation function shall return \keyword{void}. +A deallocation function shall have a declared return type \keyword{void}. A deallocation function shall not have a potentially throwing exception specification\iref{except.spec}. If the function is a destroying operator delete @@ -5175,7 +5199,7 @@ sequence of \placeholder{N} \tcode{\keyword{unsigned} \keyword{char}} objects taken up by a non-bit-field complete object of type \tcode{T}, where \placeholder{N} equals -\tcode{\keyword{sizeof}(T)}. +\tcode{\keyword{sizeof}(T)}\iref{expr.sizeof}. The \defnx{value representation}{representation!value} of a type \tcode{T} is the set of bits in the object representation of \tcode{T} @@ -5199,6 +5223,12 @@ with that of the C programming language. \end{footnote} +\pnum +For any complete object type, +its size and the presence and placement of padding +does not vary within a program +(including during constant evaluation\iref{expr.const}). + \pnum \indextext{type!incompletely-defined object}% A class that has been declared but not defined, an enumeration type in certain @@ -5632,6 +5662,10 @@ however, unscoped enumerations can be promoted to integral types as specified in \ref{conv.prom}. \end{note} +If the bits in the value representation of an object of integer type +all have value zero, +the object contains the value \tcode{false} +if it is of type \keyword{bool} and zero otherwise. \pnum \indextext{floating-point type|see{type, floating-point}}% diff --git a/source/classes.tex b/source/classes.tex index 264660aab5..bf00cb776a 100644 --- a/source/classes.tex +++ b/source/classes.tex @@ -1144,10 +1144,32 @@ \begin{itemize} \item the function is not deleted, \item the associated constraints\iref{temp.constr}, if any, are satisfied, and -\item no special member function of the same kind -whose associated constraints, if any, are satisfied -is more constrained\iref{temp.constr.order}. +\item there exists no special member function + \begin{itemize} + \item that is of the same kind, + \item that is not more explicit, + \item whose associated constraints, if any, are satisfied, and + \item that is more constrained\iref{temp.constr.order}, + \end{itemize} +where a function \tcode{F1} is more explicit than a function \tcode{F2} +if \tcode{F1} is explicit\iref{dcl.fct.spec} and \tcode{F2} is not. \end{itemize} +\begin{example} +\begin{codeblock} +template +struct X { + X() = default; + X(const X&) = default; // \#1 +private: + explicit X(const X&) requires true = default; // \#2 +}; + +int main() { + X x; + X x2 = x; // OK, selects \#1; both \#1 and \#2 are eligible +} +\end{codeblock} +\end{example} \pnum For a class, its direct non-static data members, its non-virtual direct base classes, @@ -1161,32 +1183,33 @@ \indextext{special member function|see{constructor}}% \pnum -A \grammarterm{declarator} declares a \defn{constructor} if it is a -function declarator\iref{dcl.fct} of the form -\begin{ncbnf} -ptr-declarator \terminal{(} parameter-declaration-clause \terminal{)} \opt{noexcept-specifier} \opt{attribute-specifier-seq} -\end{ncbnf} -where the \grammarterm{ptr-declarator} consists solely of an -\grammarterm{id-expression}, an optional \grammarterm{attribute-specifier-seq}, -and optional surrounding parentheses, and the \grammarterm{id-expression} has -one of the following forms: +A \grammarterm{declaration} declares a \defn{constructor} if \begin{itemize} \item in a friend declaration\iref{class.friend}, -the \grammarterm{id-expression} is a \grammarterm{qualified-id} -that names a constructor\iref{class.qual}; +the \grammarterm{declarator-id} is a \grammarterm{qualified-id} that +names a constructor\iref{class.qual}; + \item -otherwise, in a \grammarterm{member-declaration} that belongs to the -\grammarterm{member-specification} of a class or class template, -the \grammarterm{id-expression} is the -injected-class-name\iref{class.pre} of the immediately-enclosing entity; +otherwise, +in a \grammarterm{member-declaration} that +belongs to the \grammarterm{member-specification} of a class or class template, +the \grammarterm{declarator-id} is the injected-class-name\iref{class.pre} of +the immediately-enclosing entity; \item -otherwise, the -\grammarterm{id-expression} is a \grammarterm{qualified-id} -whose \grammarterm{unqualified-id} is -the injected-class-name of its lookup context. +otherwise, +the \grammarterm{declarator-id} is a \grammarterm{qualified-id} whose +\grammarterm{unqualified-id} is the injected-class-name of its lookup context. \end{itemize} + +The declarator of a constructor declaration shall have the form +\begin{ncbnf} +ptr-declarator \terminal{(} parameter-declaration-clause \terminal{)} \opt{noexcept-specifier} \opt{attribute-specifier-seq} +\end{ncbnf} +where the \grammarterm{ptr-declarator} consists solely of an +\grammarterm{id-expression}, an optional \grammarterm{attribute-specifier-seq}, +and optional surrounding parentheses. Constructors do not have names. In a constructor declaration, each \grammarterm{decl-specifier} in the optional \grammarterm{decl-specifier-seq} shall be @@ -3104,6 +3127,41 @@ within a nested class has no special access rights to members of an enclosing class. +\rSec2[class.mem.ambig]{Ambiguity resolution} + +\pnum +An ambiguity can arise in a \grammarterm{member-declaration} when +a \grammarterm{type-name} is enclosed in parentheses. +In this case, the choice is between +the declaration of a function with an unnamed parameter and +the declaration of a member with redundant parentheses +around the \grammarterm{declarator-id}. +If the former interpretation would declare a function whose +name is the injected-class-name of +the enclosing class or class template and +its \grammarterm{decl-specifier-seq}, if present, +would contain neither \keyword{friend} nor a \grammarterm{decl-specifier} that +is not permitted for a constructor\iref{class.ctor.general}, +the former interpretation is chosen +(i.e. the \grammarterm{type-name} +is considered a \grammarterm{simple-type-specifier} +rather than a \grammarterm{declarator-id}); +otherwise, the latter interpretation is chosen. +As in \ref{stmt.ambig}, the disambiguation +is purely syntactic and +can result in an ill-formed interpretation. +\begin{example} +\begin{codeblock} +typedef int t1, t2; +template struct u1; +struct A { + A(t1); // OK, declares constructor having unnamed parameter of type \tcode{int}, not a data member named \tcode{t1} + typedef A(t2); // OK, declares \tcode{t2} as an alias for \tcode{A} + A(u1); // error: placeholder for deduced class type cannot appear in this context\iref{dcl.type.class.deduct} +}; +\end{codeblock} +\end{example} + \rSec1[class.union]{Unions}% \rSec2[class.union.general]{General}% @@ -3371,8 +3429,12 @@ \indextext{class!local|see{local class}}% \pnum -A class can be declared within a function definition; such a class is -called a \defnadj{local}{class}. +\indextext{nested class!local class}% +A class is a \defnadj{local}{class} if +\begin{itemize} +\item its declaration inhabits a block scope or +\item it is a nested class of a local class. +\end{itemize} \begin{note} A declaration in a local class cannot odr-use\iref{term.odr.use} @@ -3414,13 +3476,10 @@ definition, if they are defined at all. \pnum -\indextext{nested class!local class}% \indextext{restriction!local class}% -A class nested within -a local class is a local class. A member of a local class \tcode{X} shall be declared only in the definition of \tcode{X} or, -if the member is a nested class, +if the member is an enumeration or a nested class, in the nearest enclosing block scope of \tcode{X}. \pnum @@ -3669,10 +3728,12 @@ class specifier that contains the keyword \keyword{virtual} specifies a \defnadj{virtual}{base class}. For each distinct occurrence of a non-virtual base class in the class lattice of the most derived class, -the most derived object\iref{intro.object} shall contain a +the most derived object\iref{intro.object} contains a corresponding distinct base class subobject of that type. For each distinct base class that is specified virtual, the most derived object -shall contain a single base class subobject of that type. +contains a single base class subobject of that type. +A \defnadj{transitively virtual}{base class} is +a virtual base class or a base class thereof. \pnum \begin{note} @@ -5843,9 +5904,9 @@ \grammarterm{mem-initializer}{s} for base classes have completed, \item -a precondition assertion of a constructor, or +a precondition assertion of a constructor of the object under construction, or \item -a postcondition assertion of a destructor\iref{dcl.contract.func}, +a postcondition assertion of the destructor of the object under destruction\iref{dcl.contract.func}, \end{itemize} the program has undefined behavior\ubdef{class.base.init.mem.fun}. \begin{example} diff --git a/source/compatibility.tex b/source/compatibility.tex index 1aee4a696d..da1146f2bb 100644 --- a/source/compatibility.tex +++ b/source/compatibility.tex @@ -2986,6 +2986,30 @@ names are referred to outside the \keyword{struct}. The latter is probably rare. +\diffref{basic.scope.block} +\change +Names declared in the outermost block scope of a \keyword{for} loop +conflict with those declared in its \grammarterm{init-statement}. +\begin{example} +\begin{codeblock} +void f() { + for (int i = 0; ; ) { + long i = 1; // valid C, invalid \Cpp + // ... + } +} +\end{codeblock} +\end{example} +\rationale +C99 introduced the possibility to declare variables in a \keyword{for} loop, +but did not add the \Cpp{} rule about conflicting declarations. +\effect +Change to semantics of well-defined feature. +\difficulty +Semantic transformation. +\howwide +Seldom. + \diffref{basic.link} [also \ref{dcl.type}] \change A name of file scope that is explicitly declared \keyword{const}, and not explicitly diff --git a/source/declarations.tex b/source/declarations.tex index 1c896f425c..448e735af1 100644 --- a/source/declarations.tex +++ b/source/declarations.tex @@ -298,8 +298,13 @@ \end{note} \pnum -A \grammarterm{nodeclspec-function-declaration} shall declare a -constructor, destructor, or conversion function. +A \grammarterm{name-declaration} that +has the form of a \grammarterm{nodeclspec-function-declaration} +is interpreted as a \grammarterm{nodeclspec-function-declaration} +if and only if its \grammarterm{declarator-id} +has one of the forms specified for the declaration of +a constructor, destructor, or conversion function +at namespace scope\iref{class.ctor.general,class.dtor,class.conv.fct}. \begin{note} Because a member function cannot be subject to a non-defining declaration outside of a class definition\iref{class.mfct}, a \grammarterm{nodeclspec-function-declaration} @@ -307,6 +312,14 @@ \grammarterm{explicit-instantiation}\iref{temp.explicit}, or \grammarterm{explicit-specialization}\iref{temp.expl.spec}. \end{note} +\begin{example} +\begin{codeblock} +struct A {}; +struct B : A {}; +B::B(A); // error: out-of-line non-defining constructor declaration +B::A(A); // OK, declares a variable named \tcode{A} having type \tcode{A} +\end{codeblock} +\end{example} \pnum If a \grammarterm{static_assert-message} @@ -1285,12 +1298,12 @@ \end{note} \pnum +\begin{note} A pointer or reference to a cv-qualified type need not actually point or refer to a cv-qualified object, but it is treated as if it does; a const-qualified access path cannot be used to modify an object even if the object referenced is a non-const object and can be modified through some other access path. -\begin{note} Cv-qualifiers are supported by the type system so that they cannot be subverted without casting\iref{expr.const.cast}. \end{note} @@ -3935,6 +3948,8 @@ void h(int x(const int)); // \#3 void h(int (*)(int)) {} // defines \#3 + +void j(int[0]); // error: \tcode{int[0]} is not a valid type \end{codeblock} \end{example} @@ -4894,9 +4909,6 @@ \pnum The \grammarterm{result-name-introducer} -of a \grammarterm{postcondition-specifier} -is a declaration. -The \grammarterm{result-name-introducer} introduces the \grammarterm{identifier} as the name of a \defn{result binding} of the associated function. @@ -5085,7 +5097,7 @@ \indextext{variable!indeterminate uninitialized}% \indextext{initialization!zero-initialization}% To \defnx{zero-initialize}{zero-initialization} -an object or reference of type \tcode{T} means: +an object or reference of type \cv{} \tcode{T} means: \begin{itemize} \item if \tcode{T} is \tcode{std::meta::info}, @@ -5104,7 +5116,7 @@ \item if \tcode{T} -is a (possibly cv-qualified) non-union class type, +is a non-union class type, its padding bits\iref{term.padding.bits} are initialized to zero bits and each non-static data member, each non-virtual base class subobject, and, @@ -5115,7 +5127,7 @@ \item if \tcode{T} -is a (possibly cv-qualified) union type, +is a union type, its padding bits\iref{term.padding.bits} are initialized to zero bits and the object's first non-static named @@ -5137,14 +5149,14 @@ To \defnx{default-initialize}{default-initialization} an object of type -\tcode{T} +\cv{} \tcode{T} means: \begin{itemize} \item If \tcode{T} -is a (possibly cv-qualified) class type\iref{class}, +is a class type\iref{class}, constructors are considered. The applicable constructors are enumerated\iref{over.match.ctor}, and the best one for the \grammarterm{initializer} \tcode{()} is chosen through @@ -5307,7 +5319,11 @@ or an array of \keyword{wchar_t}, and the initializer is a \grammarterm{string-literal}, see~\ref{dcl.init.string}. -\item If the initializer is \tcode{()}, the object is value-initialized. +\item If the initializer is of the form +\tcode{(} \opt{\grammarterm{expression-list}} \tcode{)} +and the \grammarterm{expression-list} is absent +(after any pack expansion\iref{temp.variadic}), +the object is value-initialized. \indextext{ambiguity!function declaration}% \begin{note} Since @@ -5914,7 +5930,7 @@ \tcode{a} and \tcode{b} have the same value. \end{example} An array of unknown bound shall not be initialized with -an empty \grammarterm{braced-init-list} \tcode{\{\}}. +a \grammarterm{braced-init-list} that has no elements. \begin{footnote} The syntax provides for empty \grammarterm{braced-init-list}{s}, but nonetheless \Cpp{} does not have zero length arrays. diff --git a/source/exceptions.tex b/source/exceptions.tex index 23e143e137..242aed541b 100644 --- a/source/exceptions.tex +++ b/source/exceptions.tex @@ -395,8 +395,11 @@ Each object with automatic storage duration is destroyed if it has been constructed, but not yet destroyed, since the try block was entered. -If an exception is thrown during the destruction of temporaries or -local variables for a \keyword{return} statement\iref{stmt.return}, +If the destruction of temporaries or local variables +for a \keyword{return} statement\iref{stmt.return} or +the evaluation of postcondition assertions of +the enclosing function\iref{expr.call} +exits via an exception, the destructor for the returned object (if any) is also invoked. The objects are destroyed in the reverse order of the completion of their construction. diff --git a/source/expressions.tex b/source/expressions.tex index bbff3d1640..0fce2f8673 100644 --- a/source/expressions.tex +++ b/source/expressions.tex @@ -448,19 +448,15 @@ \item if \tcode{T1} is -``pointer to member of \tcode{C1} of type \cvqual{cv1} \tcode{U}'' and +``pointer to member of \tcode{C1} of type \tcode{U1}'' and \tcode{T2} is -``pointer to member of \tcode{C2} of type \cvqual{cv2} \tcode{U}'', -for some non-function type \tcode{U}, +``pointer to member of \tcode{C2} of type \tcode{U2}'', +for similar types \tcode{U1} and \tcode{U2}, where \tcode{C1} is reference-related to \tcode{C2} or \tcode{C2} is reference-related to -\tcode{C1}\iref{dcl.init.ref}, the qualification-combined type of \tcode{T2} and \tcode{T1} or the qualification-combined type +\tcode{C1}, the qualification-combined type of \tcode{T2} and \tcode{T1} or the qualification-combined type of \tcode{T1} and \tcode{T2}, respectively; -\item -if \tcode{T1} and \tcode{T2} are similar types\iref{conv.qual}, the qualification-combined type of \tcode{T1} and -\tcode{T2}; - \item otherwise, a program that necessitates the determination of a composite pointer type is ill-formed. @@ -1006,15 +1002,16 @@ \pnum \indextext{conversion!bool@\tcode{bool}}% -If the destination type is \keyword{bool}, see~\ref{conv.bool}. If the -source type is \keyword{bool}, the value \keyword{false} is converted to -zero and the value \keyword{true} is converted to one. +If the destination type is \keyword{bool}, see~\ref{conv.bool}. +If the source type is \keyword{bool}, +the source integer value is considered to be zero if +the value is \tcode{false} and one otherwise. \pnum \indextext{conversion!to unsigned}% \indextext{conversion!to signed}% -Otherwise, the result is the unique value of the destination type -that is congruent to the source integer modulo $2^N$, +The result is the unique value of the destination type +that is congruent to the source integer value modulo $2^N$, where $N$ is the width of the destination type. \pnum @@ -1120,8 +1117,8 @@ If \tcode{v} is a null pointer value, the result is a null pointer value. Otherwise, -if \tcode{B} is a virtual base class of \tcode{D} -or is a base class of a virtual base class of \tcode{D} and +if \tcode{B} is a transitively virtual base class of \tcode{D}\iref{class.mi} +and \tcode{v} does not point to an object whose type is similar\iref{conv.qual} to \tcode{D} and that is @@ -1156,9 +1153,10 @@ \tcode{T}'', where \tcode{D} is a complete class derived\iref{class.derived} from \tcode{B}. If \tcode{B} is an inaccessible\iref{class.access}, -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. +ambiguous\iref{class.member.lookup}, or +transitively virtual\iref{class.mi} +base class of \tcode{D}, +a program that necessitates this conversion is ill-formed. 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\ubdef{conv.member.missing.member}. @@ -4186,11 +4184,11 @@ lvalue-to-rvalue\iref{conv.lval}, array-to-pointer\iref{conv.array}, and function-to-pointer\iref{conv.func} standard conversions are performed on the argument expression. -An argument that has type \cv{}~\tcode{std::nullptr_t} is converted -to type \tcode{\keyword{void}*}\iref{conv.ptr}. +Then, an argument that has type \tcode{std::nullptr_t} is converted +to type ``pointer to \keyword{void}''\iref{conv.ptr}. After these conversions, if the -argument does not have arithmetic, enumeration, pointer, pointer-to-member, -or class type, the program is ill-formed. +argument has type \keyword{void}, +the program is ill-formed. Passing a potentially evaluated argument of a scoped enumeration type\iref{dcl.enum} or of a class type\iref{class} having @@ -4853,8 +4851,8 @@ \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} -or a base class of a virtual base class of \tcode{D}, +\cvqual{cv1}. +If \tcode{B} is a transitively virtual base class of \tcode{D}\iref{class.mi} or if no valid standard conversion from ``pointer to \tcode{D}'' to ``pointer to \tcode{B}'' exists\iref{conv.ptr}, the program is ill-formed. An xvalue of type @@ -4990,8 +4988,7 @@ 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} or -a base class of a virtual base class of \tcode{D}, or +If \tcode{B} is a transitively virtual base class of \tcode{D}\iref{class.mi} or if no valid standard conversion from ``pointer to \tcode{D}'' to ``pointer to \tcode{B}'' exists\iref{conv.ptr}, the program is ill-formed. The null pointer value\iref{basic.compound} is converted @@ -8622,7 +8619,10 @@ \begin{itemize} \item in a constexpr function\iref{dcl.constexpr} -that is being evaluated as part of $E$ or +that is being evaluated as part of $E$, +\item +in a default member initializer for an object +that is being initialized as part of $E$, or \item when appearing as the \grammarterm{postfix-expression} of an implicit or explicit class member access expression\iref{expr.ref}; diff --git a/source/lex.tex b/source/lex.tex index 34948244d5..b132a2a502 100644 --- a/source/lex.tex +++ b/source/lex.tex @@ -415,6 +415,10 @@ the value of such a code unit can be the same as that of a code unit for an element of the basic literal character set. \end{note} +If the implementation does not define +the preprocessor macro \mname{STDC_MB_MIGHT_NEQ_WC}\iref{cpp.predefined}, +each element of the basic character set has the same code unit value in +the ordinary literal encoding and the wide literal encoding. \indextext{character!null}% \indextext{wide-character!null}% The \unicode{0000}{null} character is encoded as the value \tcode{0}. @@ -659,8 +663,9 @@ except that \begin{itemize} \item -a \grammarterm{string-literal} token is never formed -when a \grammarterm{header-name} token can be formed, and +%%FIXME: What's a "different kind" of preprocessing token?? +a different kind of preprocessing token is never formed +when a \grammarterm{header-name} preprocessing token can be formed, and \item a \grammarterm{header-name}\iref{lex.header} is only formed \begin{itemize} diff --git a/source/preprocessor.tex b/source/preprocessor.tex index 7ddec0a17e..59791a290f 100644 --- a/source/preprocessor.tex +++ b/source/preprocessor.tex @@ -1310,6 +1310,10 @@ \pnum The \tcode{module} and \tcode{export} (if it exists) preprocessing tokens +of a +\grammarterm{pp-module}, +\grammarterm{pp-global-module-fragment}, or +\grammarterm{pp-private-module-fragment} are replaced by the \grammarterm{module-keyword} and \grammarterm{export-keyword} preprocessing tokens respectively. \begin{note} @@ -1730,11 +1734,9 @@ are separated by comma preprocessing tokens, but comma preprocessing tokens between matching inner parentheses do not separate arguments. -If there are sequences of preprocessing tokens within the list of -arguments that would otherwise act as preprocessing directives, -\begin{footnote} -A \grammarterm{conditionally-supported-directive} is a preprocessing directive regardless of whether the implementation supports it. -\end{footnote} +If there is whitespace containing at least one new-line character +immediately followed by a directive-introducing token\iref{cpp.pre} +within the list of arguments, the program is ill-formed. \pnum @@ -2367,6 +2369,16 @@ the integer literal \tcode{0} if it is a freestanding implementation\iref{intro.compliance}. +\item +\indextext{__stdc_utf_16__@\mname{STDC_UTF_16}}% +\mname{STDC_UTF_16}\\ +The integer literal \tcode{1}. + +\item +\indextext{__stdc_utf_32__@\mname{STDC_UTF_32}}% +\mname{STDC_UTF_32}\\ +The integer literal \tcode{1}. + \item \indextext{__stdcpp_default_new_alignment__@\mname{STDCPP_DEFAULT_NEW_ALIGNMENT}}% \mname{STDCPP_DEFAULT_NEW_ALIGNMENT}\\ @@ -2537,7 +2549,7 @@ \mname{STDC_MB_MIGHT_NEQ_WC}\\ The integer literal \tcode{1}, intended to indicate that, in the encoding for \keyword{wchar_t}, a member of the basic character set need not have a code value equal to -its value when used as the lone character in an ordinary character literal. +its value when used as the lone character in an ordinary character literal\iref{lex.charset}. \item \indextext{__stdc_version__@\mname{STDC_VERSION}}% diff --git a/source/statements.tex b/source/statements.tex index 846b203c04..0386f87b11 100644 --- a/source/statements.tex +++ b/source/statements.tex @@ -818,14 +818,18 @@ \pnum For an expression \tcode{E}, let the expressions -\exposid{begin-expr} and \exposid{end-expr} be determined as specified in~\ref{stmt.ranged}. +\exposid{begin-expr} and \exposid{end-expr} be determined as specified in~\ref{stmt.ranged}, +except that the exposition-only variable \exposid{range} +is defined by the hypothetical declaration +\tcode{decltype(auto) \exposid{range} = (E);}. An expression is \defn{expansion-iterable} if it does not have array type and either \begin{itemize} \item \exposid{begin-expr} and \exposid{end-expr} are of the form -\tcode{E.begin()} and \tcode{E.end()}, or +\tcode{\exposid{range}.begin()} and \tcode{\exposid{range}.end()}, or \item -argument-dependent lookups for \tcode{begin(E)} and for \tcode{end(E)} +argument-dependent lookups +for \tcode{begin(\exposid{range})} and for \tcode{end(\exposid{range})} each find at least one viable candidate\iref{over.match.viable}. \end{itemize} @@ -941,8 +945,11 @@ If the \grammarterm{expansion-initializer} is an lvalue, then $v_{i}$ is $u_{i}$; otherwise, $v_{i}$ is \tcode{static_cast($u_{i}$)}. -The keyword \keyword{constexpr} is present in the \grammarterm{structured-binding-declaration} -of $u_{0}, u_{1}, \dotsc, u_{N-1}$ if and only if +The keyword \keyword{constexpr} is present in +the declaration of \exposid{range} or +the \grammarterm{structured-binding-declaration} +of $u_{0}, u_{1}, \dotsc, u_{N-1}$, respectively, +if and only if \keyword{constexpr} is one of the \grammarterm{decl-specifier}s of the \grammarterm{decl-specifier-seq} of the \grammarterm{for-range-declaration}. diff --git a/source/templates.tex b/source/templates.tex index a33c36d706..61fd6429f8 100644 --- a/source/templates.tex +++ b/source/templates.tex @@ -634,13 +634,13 @@ \pnum If a \grammarterm{template-parameter} -of a class template, variable template, or alias template has +of a class template, variable template, concept, or alias template has a default template argument, each subsequent \grammarterm{template-parameter} shall either have a default template argument supplied or declare a template parameter pack. If a \grammarterm{template-parameter} of -a primary class template, primary variable template, or alias template +a primary class template, primary variable template, concept, or alias template declares a template parameter pack, it shall be the last \grammarterm{template-parameter}. If a \grammarterm{template-parameter} of a function template @@ -3378,7 +3378,10 @@ \pnum A pack whose name appears within the pattern of a pack -expansion is expanded by that pack expansion. An appearance of the name of +expansion is expanded by that pack expansion +if the target scope of the declaration of the pack +contains the point of the pack expansion. +An appearance of the name of a pack is only expanded by the innermost enclosing pack expansion. The pattern of a pack expansion shall name one or more packs that are not expanded by a nested pack expansion; such packs are called @@ -3386,6 +3389,17 @@ by a pack expansion shall have the same number of arguments specified. An appearance of a name of a pack that is not expanded is ill-formed. +%%FIXME: Is this supposed to be part of the next example? +%%FIXME: That already references an incompatible "h". +\begin{example} +\begin{codeblock} +int h(auto) { + ([](auto ...xs){ xs; }, ...); // error: unexpanded pack +} +\end{codeblock} +\end{example} +%%FIXME: What are "f" and "h" in this example? +%%FIXME: Bad example - incomplete and shouldn't redefine existing librtary functions! \begin{example} \begin{codeblock} template struct Tuple {}; @@ -5141,7 +5155,7 @@ 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 +and that templated entity or substatement is not instantiated, or \item no valid specialization, ignoring \grammarterm{static_assert-declaration}s that fail, @@ -5161,8 +5175,10 @@ no satisfaction check of $A$ could be well-formed and no satisfaction check of $A$ is performed, or \item -every valid specialization of a variadic template requires an empty template -parameter pack, or +there exists a template parameter pack \tcode{P} of +a variadic template \tcode{TT} such that no valid specialization, +ignoring \grammarterm{static_assert-declaration}{s} that fail, +can be generated for \tcode{TT} when \tcode{P} is non-empty, or \item a hypothetical instantiation of a templated entity immediately following its definition