Skip to content

Commit 9e59884

Browse files
authored
Merge 2018-06 CWG Motion 12
Fixes #2124
2 parents b37a659 + 8d2fc2e commit 9e59884

File tree

2 files changed

+45
-2
lines changed

2 files changed

+45
-2
lines changed

source/compatibility.tex

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1872,6 +1872,49 @@
18721872
if those entities are only referenced in contexts
18731873
that do not result in an odr-use.
18741874

1875+
\rSec2[diff.cpp17.dcl.decl]{\ref{dcl.decl}: declarators}
1876+
1877+
\diffref{dcl.init.aggr}
1878+
\change A class that has user-declared constructors is never an aggregate.
1879+
\rationale Remove potentially error-prone aggregate initialization
1880+
which may apply notwithstanding the declared constructors of a class.
1881+
\effect Valid \CppXVII{} code that aggregate-initializes
1882+
a type with a user-declared constructor
1883+
may be ill-formed or have different semantics
1884+
in this International Standard.
1885+
\begin{codeblock}
1886+
struct A { // not an aggregate; previously an aggregate
1887+
A() = delete;
1888+
};
1889+
1890+
struct B { // not an aggregate; previously an aggregate
1891+
B() = default;
1892+
int i = 0;
1893+
};
1894+
1895+
struct C { // not an aggregate; previously an aggregate
1896+
C(C&&) = default;
1897+
int a, b;
1898+
};
1899+
1900+
A a{}; // ill-formed; previously well-formed
1901+
B b = {1}; // ill-formed; previously well-formed
1902+
auto* c = new C{2, 3}; // ill-formed; previously well-formed
1903+
1904+
struct Y;
1905+
1906+
struct X {
1907+
operator Y();
1908+
};
1909+
1910+
struct Y { // not an aggregate; previously an aggregate
1911+
Y(const Y&) = default;
1912+
X x;
1913+
};
1914+
1915+
Y y{X{}}; // copy constructor call; previously aggregate-initialization
1916+
\end{codeblock}
1917+
18751918
\rSec2[diff.cpp17.special]{\ref{special}: special member functions}
18761919

18771920
\diffrefs{class.ctor}{class.dtor}

source/declarators.tex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2953,7 +2953,7 @@
29532953
An \defn{aggregate} is an array or a class\iref{class} with
29542954
\begin{itemize}
29552955
\item
2956-
no user-provided, \tcode{explicit}, or inherited constructors\iref{class.ctor},
2956+
no user-declared or inherited constructors\iref{class.ctor},
29572957
\item
29582958
no private or protected non-static data members\iref{class.access},
29592959
\item
@@ -3456,7 +3456,7 @@
34563456
\indextext{initialization!array of class objects}%
34573457
\begin{note}
34583458
An aggregate array or an aggregate class may contain elements of a
3459-
class type with a user-provided constructor\iref{class.ctor}.
3459+
class type with a user-declared constructor\iref{class.ctor}.
34603460
Initialization of these aggregate objects is described in~\ref{class.expl.init}.
34613461
\end{note}
34623462

0 commit comments

Comments
 (0)