Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
4eb910d
CWG3025 Deallocation functions returning void
burblebee Nov 22, 2026
d81c52a
CWG3121 Zero-size arrays in function parameters
burblebee Nov 22, 2026
7d0a60b
CWG3137 Composite pointer type with qualification and pointer-to-memb…
burblebee Nov 22, 2026
9716e52
CWG3144 Granularity of implementation choice for sizeof and subobject…
burblebee Nov 22, 2026
2abddfb
CWG3160 Grammar ambiguity with class member declarations
burblebee Nov 22, 2026
49d98aa
CWG3163 Grammar ambiguity for nodeclspec-function-declaration
burblebee Nov 22, 2026
9e01e05
CWG3192 Out-of-line definition of an enum member of a local class
burblebee Nov 22, 2026
8b4088f
CWG3194 Lexing of <=>
burblebee Nov 22, 2026
2e9b288
CWG3197 Relaxed requirements for integer representations
burblebee Nov 22, 2026
5251688
CWG3199 Missing predefined macros for char16_t and char32_t
burblebee Nov 22, 2026
b6aef25
CWG3200 Qualified pointer pointing to unqualified object
burblebee Nov 22, 2026
c976743
CWG3201 Zero- and default-initialization of cv-qualified std::meta::info
burblebee Nov 22, 2026
e0a397d
CWG3204 Restrictions on arguments for ellipsis parameter
burblebee Nov 23, 2026
79e44bf
CWG3206 Scattered definition of "local class"
burblebee Nov 23, 2026
dea93a0
CWG3208 Base classes of virtual base classes
burblebee Nov 23, 2026
9d88ede
[basic.life] Add ", or" to list item
tkoeppe Nov 29, 2026
47a5d59
CWG3210 constexpr for empty destructuring expansion statements
burblebee Nov 23, 2026
3a05d92
CWG3211 Explicitly captured variable is not odr-usable in lambda cont…
burblebee Nov 23, 2026
9452fe5
CWG3213 Restrictions on the template-head of a concept definition
burblebee Nov 23, 2026
cfe9b79
CWG3214 Redeclaration of types and namespaces and their aliases
burblebee Nov 23, 2026
f1b560e
CWG3215 this in a default member initializer during constant evaluation
burblebee Nov 23, 2026
352a6d1
CWG3218 Expanding packs created within a pack expansion
burblebee Nov 23, 2026
7b7e467
CWG3221 Missing Annex C entry for conflicting declarations in for-loops
burblebee Nov 23, 2026
5aa3373
CWG3222 Deleted module directives
burblebee Nov 23, 2026
abd00c5
CWG3223 Undefined behavior for constructor preconditions and destruct…
burblebee Nov 23, 2026
fbc708e
CWG3224 Directives in multi-line macro arguments
burblebee Nov 23, 2026
549e82b
CWG3225 Conversion of bool to signed integer of width 1
burblebee Nov 23, 2026
f78a0ee
CWG3226 Conflict of templated entity vs. enclosing template
burblebee Nov 23, 2026
36f349a
CWG3227 IFNDR for always-empty packs
burblebee Nov 23, 2026
d199cc5
CWG3228 Empty initializers vs. empty packs
burblebee Nov 23, 2026
351c217
CWG3229 Incomplete restrictions on same meaning for same tokens
burblebee Nov 23, 2026
f10a8bc
CWG3230 Are non-static data members "variables"?
burblebee Nov 23, 2026
09a6b77
CWG3234 explicit and eligible constructors
burblebee Nov 23, 2026
3f95c21
CWG3235 begin-expr and end-expr should refer to range
burblebee Nov 23, 2026
fb2412d
CWG3237 Missing restrictions imposed by __STDC_MB_MIGHT_NEQ_WC__
burblebee Nov 23, 2026
3b990ed
CWG3238 Postcondition result bindings as declarations
burblebee Nov 23, 2026
4c28e69
CWG3240 Return object destruction from throwing postcondition evaluation
burblebee Nov 23, 2026
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
75 changes: 53 additions & 22 deletions source/basic.tex
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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}

Expand Down Expand Up @@ -826,10 +834,12 @@
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.
\item In each such definition,
operators referred to,
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
Expand Down Expand Up @@ -3067,10 +3077,20 @@
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
Expand All @@ -3079,6 +3099,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}.
Expand Down Expand Up @@ -4032,14 +4053,13 @@
program has undefined behavior if:
\begin{itemize}
\item
the pointer is used as the operand of a \grammarterm{delete-expression}\ubdef{lifetime.outside.pointer.delete},
the pointer is used as the operand of a \grammarterm{delete-expression}\ubdef{lifetime.outside.pointer.delete}, or
\item
the pointer is used to access a non-static data member or call a
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}.
Expand Down Expand Up @@ -4089,7 +4109,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}.
Expand Down Expand Up @@ -4675,7 +4696,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
Expand Down Expand Up @@ -5177,7 +5198,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}
Expand All @@ -5201,6 +5222,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
Expand Down Expand Up @@ -5634,6 +5661,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}}%
Expand Down
126 changes: 93 additions & 33 deletions source/classes.tex
Original file line number Diff line number Diff line change
Expand Up @@ -1144,10 +1144,33 @@
\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<class T>
struct X {
X() = default;
X(const X&) = default; // \#1

private:
explicit X(const X&) requires true = default; // \#2
};

int main() {
X<int> x;
X<int> 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,
Expand All @@ -1161,32 +1184,30 @@
\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
Expand Down Expand Up @@ -3104,6 +3125,42 @@
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<class> 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}%
Expand Down Expand Up @@ -3371,8 +3428,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}
Expand Down Expand Up @@ -3414,13 +3475,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
Expand Down Expand Up @@ -3669,10 +3727,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}
Expand Down Expand Up @@ -5843,9 +5903,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}
Expand Down
24 changes: 24 additions & 0 deletions source/compatibility.tex
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading
Loading