Skip to content

Commit cfd9720

Browse files
committed
Merge 2018-03 CWG Motion 1
2 parents 7066a90 + 9192d65 commit cfd9720

File tree

10 files changed

+178
-108
lines changed

10 files changed

+178
-108
lines changed

source/basic.tex

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1141,16 +1141,18 @@
11411141
\indextext{scope name hiding and}%
11421142
\indextext{name hiding}%
11431143
\indextext{hiding|see{name hiding}}%
1144-
A name can be hidden by an explicit declaration of that same name in a
1145-
nested declarative region or derived class\iref{class.member.lookup}.
1144+
A declaration of a name in a nested declarative region
1145+
hides a declaration of the same name in an enclosing declarative region;
1146+
see \ref{basic.scope.declarative} and \ref{basic.lookup.unqual}.
11461147

11471148
\pnum
11481149
\indextext{name hiding}%
1149-
A class name\iref{class.name} or enumeration name\iref{dcl.enum} can
1150-
be hidden by the name of a variable, data member, function, or enumerator declared in
1151-
the same scope. If a class or enumeration name and a variable, data member, function,
1152-
or enumerator are declared in the same scope (in any order) with the
1153-
same name, the class or enumeration name is hidden wherever the variable, data member,
1150+
If a class name\iref{class.name} or enumeration name\iref{dcl.enum} and
1151+
a variable, data member, function, or enumerator
1152+
are declared in the same declarative region (in any order) with the
1153+
same name (excluding declarations made visible
1154+
via \grammarterm{using-directive}{s}\iref{basic.lookup.unqual}),
1155+
the class or enumeration name is hidden wherever the variable, data member,
11541156
function, or enumerator name is visible.
11551157

11561158
\pnum
@@ -2470,21 +2472,12 @@
24702472
\item it is a cv-qualified\iref{basic.type.qualifier} version of a
24712473
type that has linkage.
24722474
\end{itemize}
2473-
A type without linkage shall not be used as the type of a variable or
2474-
function with external linkage unless
2475-
\begin{itemize}
2476-
\item the entity has C language linkage\iref{dcl.link}, or
2477-
2478-
\item the entity is not odr-used\iref{basic.def.odr} or is defined in
2479-
the same translation unit.
2480-
\end{itemize}
24812475
\begin{note}
24822476
In other words, a type without linkage contains a class or enumeration that
2483-
cannot be named outside its translation unit. An entity with external linkage declared
2484-
using such a type could not correspond to any other entity in another translation unit
2485-
of the program and thus must be defined in the
2486-
translation unit if it is odr-used. Also note that classes with linkage may contain members
2487-
whose types do not have linkage, and that typedef names are ignored in the determination
2477+
cannot be named outside its translation unit.
2478+
Classes with linkage may contain members
2479+
whose types do not have linkage.
2480+
Typedef names are ignored in the determination
24882481
of whether a type has linkage.
24892482
\end{note}
24902483

@@ -2501,7 +2494,7 @@
25012494
A a = { 1 };
25022495
B<A> ba; // declares \tcode{B<A>::g(A)} and \tcode{B<A>::h(A)}
25032496
ba.g(a); // OK
2504-
ba.h(a); // error: \tcode{B<A>::h(A) not defined in the translation unit}
2497+
ba.h(a); // error: \tcode{B<A>::h(A)} not defined; \tcode{A} cannot be named in another translation unit
25052498
i(ba, a); // OK
25062499
}
25072500
\end{codeblock}
@@ -3236,10 +3229,11 @@
32363229
class\iref{class.free}.
32373230

32383231
\pnum
3239-
Any allocation and/or deallocation functions defined in a \Cpp{} program,
3240-
including the default versions in the library, shall conform to the
3241-
semantics specified in~\ref{basic.stc.dynamic.allocation}
3242-
and~\ref{basic.stc.dynamic.deallocation}.
3232+
If the behavior of an allocation or deallocation function
3233+
does not satisfy the semantic constraints
3234+
specified in~\ref{basic.stc.dynamic.allocation}
3235+
and~\ref{basic.stc.dynamic.deallocation},
3236+
the behavior is undefined.
32433237

32443238
\rSec4[basic.stc.dynamic.allocation]{Allocation functions}
32453239

@@ -3251,37 +3245,41 @@
32513245
global scope. The return type shall be \tcode{void*}. The first
32523246
parameter shall have type \tcode{std::size_t}\iref{support.types}. The
32533247
first parameter shall not have an associated default
3254-
argument\iref{dcl.fct.default}. The value of the first parameter shall
3255-
be interpreted as the requested size of the allocation. An allocation
3248+
argument\iref{dcl.fct.default}. The value of the first parameter
3249+
is interpreted as the requested size of the allocation. An allocation
32563250
function can be a function template. Such a template shall declare its
32573251
return type and first parameter as specified above (that is, template
32583252
parameter types shall not be used in the return type and first parameter
32593253
type). Template allocation functions shall have two or more parameters.
32603254

32613255
\pnum
3262-
The allocation function attempts to allocate the requested amount of
3263-
storage. If it is successful, it shall return the address of the start
3264-
of a block of storage whose length in bytes shall be at least as large
3265-
as the requested size. There are no constraints on the contents of the
3266-
allocated storage on return from the allocation function. The order,
3256+
An allocation function attempts to allocate the requested amount of
3257+
storage. If it is successful, it returns the address of the start
3258+
of a block of storage whose length in bytes is at least as large
3259+
as the requested size.
3260+
The order,
32673261
contiguity, and initial value of storage allocated by successive calls
3268-
to an allocation function are unspecified. The pointer returned shall be
3262+
to an allocation function are unspecified.
3263+
For an allocation function other than
3264+
a reserved placement allocation function\iref{new.delete.placement},
3265+
the pointer returned is
32693266
suitably aligned so that it can be converted to a pointer to any
32703267
suitable complete object type\iref{new.delete.single}
32713268
and then used to access the object or array in the
32723269
storage allocated (until the storage is explicitly deallocated by a call
32733270
to a corresponding deallocation function). Even if the size of the space
32743271
requested is zero, the request can fail. If the request succeeds, the
3275-
value returned shall be a non-null pointer value\iref{conv.ptr}
3272+
value returned by a replaceable allocation function
3273+
is a non-null pointer value\iref{conv.ptr}
32763274
\tcode{p0} different from any previously returned value \tcode{p1},
3277-
unless that value \tcode{p1} was subsequently passed to an
3278-
\tcode{operator} \tcode{delete}.
3275+
unless that value \tcode{p1} was subsequently passed to a
3276+
replaceable deallocation function.
32793277
Furthermore, for the library allocation functions
32803278
in~\ref{new.delete.single} and~\ref{new.delete.array},
3281-
\tcode{p0} shall represent the address of a block of storage disjoint from the storage
3279+
\tcode{p0} represents the address of a block of storage disjoint from the storage
32823280
for any other object accessible to the caller.
32833281
The effect of indirecting through a pointer
3284-
returned as a request for zero size is undefined.\footnote{The intent is
3282+
returned from a request for zero size is undefined.\footnote{The intent is
32853283
to have \tcode{operator new()} implementable by
32863284
calling \tcode{std::malloc()} or \tcode{std::calloc()}, so the rules are
32873285
substantially the same. \Cpp{} differs from C in requiring a zero request
@@ -3295,11 +3293,13 @@
32953293
A program-supplied allocation function can obtain the address of the
32963294
currently installed \tcode{new_handler} using the
32973295
\tcode{std::get_new_handler} function\iref{set.new.handler}. \end{note}
3298-
If an allocation function that has a non-throwing
3296+
An allocation function that has a non-throwing
32993297
exception specification\iref{except.spec}
3300-
fails to allocate storage, it shall return a null pointer. Any other
3301-
allocation function that fails to allocate storage shall indicate
3302-
failure only by throwing an exception\iref{except.throw} of a type
3298+
indicates failure by returning
3299+
a null pointer value.
3300+
Any other allocation function
3301+
never returns a null pointer value and
3302+
indicates failure only by throwing an exception\iref{except.throw} of a type
33033303
that would match a handler\iref{except.handle} of type
33043304
\tcode{std::bad_alloc}\iref{bad.alloc}.
33053305

source/classes.tex

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@
5555
\terminal{union}
5656
\end{bnf}
5757

58+
A class declaration where the \grammarterm{class-name}
59+
in the \grammarterm{class-head-name} is a \grammarterm{simple-template-id}
60+
shall be an explicit specialization\iref{temp.expl.spec} or
61+
a partial specialization\iref{temp.class.spec}.
5862
A \grammarterm{class-specifier} whose
5963
\grammarterm{class-head} omits the
6064
\grammarterm{class-head-name} defines an unnamed class. \begin{note} An unnamed class thus can't
@@ -637,7 +641,7 @@
637641
A \grammarterm{virt-specifier-seq} shall contain at most one of each
638642
\grammarterm{virt-specifier}.
639643
A \grammarterm{virt-specifier-seq}
640-
shall appear only in the declaration of a virtual member
644+
shall appear only in the first declaration of a virtual member
641645
function\iref{class.virtual}.
642646

643647
\pnum
@@ -1330,6 +1334,7 @@
13301334
A declaration for a bit-field that omits the \grammarterm{identifier}
13311335
declares an \defn{unnamed bit-field}. Unnamed bit-fields are not
13321336
members and cannot be initialized.
1337+
An unnamed bit-field shall not be declared with a cv-qualified type.
13331338
\begin{note}
13341339
An unnamed bit-field is useful for padding to conform to
13351340
externally-imposed layouts.

source/compatibility.tex

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -873,7 +873,7 @@
873873
this International Standard. Specifically, macros named \tcode{R}, \tcode{u8},
874874
\tcode{u8R}, \tcode{u}, \tcode{uR}, \tcode{U}, \tcode{UR}, or \tcode{LR} will
875875
not be expanded when adjacent to a string literal but will be interpreted as
876-
part of the string literal. For example,
876+
part of the string literal. For example:
877877

878878
\begin{codeblock}
879879
#define u8 "abc"
@@ -885,7 +885,8 @@
885885
\rationale Required for new features.
886886
\effect
887887
Valid \CppIII{} code may fail to compile or produce different results in
888-
this International Standard, as the following example illustrates.
888+
this International Standard.
889+
For example:
889890

890891
\begin{codeblock}
891892
#define _x "there"
@@ -929,7 +930,8 @@
929930
\rationale Removing surprising interactions with templates and constant
930931
expressions.
931932
\effect Valid \CppIII{} code may fail to compile or produce different results in
932-
this International Standard, as the following example illustrates:
933+
this International Standard.
934+
For example:
933935

934936
\begin{codeblock}
935937
void f(void *); // \#1
@@ -954,7 +956,8 @@
954956
\rationale Required for new features.
955957
\effect
956958
Valid \CppIII{} code may fail to compile or produce different results in
957-
this International Standard, as the following example illustrates:
959+
this International Standard.
960+
For example:
958961

959962
\begin{codeblock}
960963
bool b1 = new int && false; // previously \tcode{false}, now ill-formed
@@ -1467,6 +1470,7 @@
14671470
by aggregate initialization.
14681471
\effect
14691472
Valid \CppXI{} code may fail to compile or may change meaning in this International Standard.
1473+
For example:
14701474
\begin{codeblock}
14711475
struct S { // Aggregate in \CppXIV{} onwards.
14721476
int m = 1;
@@ -1530,6 +1534,7 @@
15301534
this International Standard. Specifically, character sequences like \tcode{0p+0}
15311535
and \tcode{0e1_p+0} are three separate tokens each in \CppXIV{}, but one single token
15321536
in this International Standard.
1537+
For example:
15331538

15341539
\begin{codeblock}
15351540
#define F(a) b ## a
@@ -1588,7 +1593,8 @@
15881593
\rationale Improve type-safety.
15891594
\effect
15901595
Valid \CppXIV{} code may fail to compile or change meaning in this
1591-
International Standard:
1596+
International Standard.
1597+
For example:
15921598

15931599
\begin{codeblock}
15941600
void g1() noexcept;
@@ -1605,7 +1611,8 @@
16051611
Valid \CppXIV{} code may fail to compile or produce different results in this
16061612
International Standard; initialization from an empty initializer list will
16071613
perform aggregate initialization instead of invoking a default constructor
1608-
for the affected types:
1614+
for the affected types.
1615+
For example:
16091616
\begin{codeblock}
16101617
struct derived;
16111618
struct base {
@@ -1655,7 +1662,8 @@
16551662
allows partial specializations to decompose
16561663
from the type deduced for the non-type template argument.
16571664
\effect Valid \CppXIV{} code may fail to compile
1658-
or produce different results in this International Standard:
1665+
or produce different results in this International Standard.
1666+
For example:
16591667
\begin{codeblock}
16601668
template <int N> struct A;
16611669
template <typename T, T N> int foo(A<N> *) = delete;
@@ -1863,6 +1871,26 @@
18631871
if those entities are only referenced in contexts
18641872
that do not result in an odr-use.
18651873

1874+
\rSec2[diff.cpp17.special]{\ref{special}: special member functions}
1875+
1876+
\diffrefs{class.ctor}{class.dtor}
1877+
\change
1878+
A \grammarterm{simple-template-id}
1879+
is no longer valid as the \grammarterm{declarator-id} of a constructor or destructor.
1880+
\rationale
1881+
Remove potentially error-prone option for redundancy.
1882+
\effect
1883+
Valid \CppXVII{} code may fail to compile
1884+
in this International Standard. For example:
1885+
\begin{codeblock}
1886+
template<class T>
1887+
struct A {
1888+
A<T>(); // error: \grammarterm{simple-template-id} not allowed for constructor
1889+
A(int); // OK, \grammarterm{injected-class-name} used
1890+
~A<T>(); // error: \grammarterm{simple-template-id} not allowed for destructor
1891+
};
1892+
\end{codeblock}
1893+
18661894
\rSec2[diff.cpp17.temp]{\ref{temp}: templates}
18671895

18681896
\diffref{temp.names}

source/declarations.tex

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1692,6 +1692,10 @@
16921692
Redeclarations or specializations of a function or function template with a
16931693
declared return type that uses a placeholder type shall also use that
16941694
placeholder, not a deduced type.
1695+
Similarly,
1696+
redeclarations or specializations of a function or function template with a
1697+
declared return type that does not use a placeholder type
1698+
shall not use a placeholder.
16951699
\begin{example}
16961700
\begin{codeblock}
16971701
auto f();

source/declarators.tex

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3160,6 +3160,16 @@
31603160
An aggregate that is a class can also be initialized with a single
31613161
expression not enclosed in braces, as described in~\ref{dcl.init}.
31623162

3163+
\pnum
3164+
The destructor for each element of class type
3165+
is potentially invoked\iref{class.dtor}
3166+
from the context where the aggregate initialization occurs.
3167+
\begin{note}
3168+
This provision ensures that destructors can be called
3169+
for fully-constructed subobjects
3170+
in case an exception is thrown\iref{except.ctor}.
3171+
\end{note}
3172+
31633173
\pnum
31643174
An array of unknown bound initialized with a
31653175
brace-enclosed

0 commit comments

Comments
 (0)