Skip to content

Commit a6064c6

Browse files
authored
Remove class.dtor.not.class.type (#7835)
1 parent 71be854 commit a6064c6

File tree

2 files changed

+1
-43
lines changed

2 files changed

+1
-43
lines changed

source/classes.tex

+1-1
Original file line numberDiff line numberDiff line change
@@ -2289,7 +2289,7 @@
22892289
that is, if the object is not of the destructor's class type and
22902290
not of a class derived from the destructor's class type (including when
22912291
the destructor is invoked via a null pointer value), the program has
2292-
undefined behavior\ubdef{class.dtor.not.class.type}.
2292+
undefined behavior.
22932293
\begin{note}
22942294
Invoking \keyword{delete} on a null pointer does not call the
22952295
destructor; see \ref{expr.delete}.

source/ub.tex

-42
Original file line numberDiff line numberDiff line change
@@ -1180,48 +1180,6 @@
11801180

11811181
\rSec2[ub.class.dtor]{Destructors}
11821182

1183-
\pnum
1184-
\ubxref{class.dtor.not.class.type} \\
1185-
The invocation of a destructor is subject to the usual rules for
1186-
member functions \iref{class.mfct}; that is, if the object is not of the destructor's class type and not of a class derived
1187-
from the destructor's class type (including when the destructor is invoked via a null pointer value), the
1188-
program has undefined behavior.
1189-
1190-
\pnum
1191-
\begin{example}
1192-
\begin{codeblock}
1193-
#include <new>
1194-
1195-
struct X {};
1196-
1197-
void f() {
1198-
X *x = nullptr;
1199-
x->~X(); // undefined behavior, invoked using a null pointer value
1200-
}
1201-
1202-
struct Y {};
1203-
void h() {
1204-
alignas(X) char buf[sizeof(X)];
1205-
X *p = new (buf) X(); // use \tcode{buf[] }and initialize
1206-
1207-
Y *yp = reinterpret_cast<Y *>(p);
1208-
yp->Y::~Y(); // undefined behavior, destructor of \tcode{Y} called for object of type \tcode{X}
1209-
}
1210-
1211-
struct Base {
1212-
virtual ~Base();
1213-
};
1214-
struct Derived : Base {};
1215-
1216-
int k() {
1217-
Base *b = new Base;
1218-
Derived *d = static_cast<Derived *>(b);
1219-
d->~Derived(); // undefined behavior, destructor of Derived call for object of
1220-
// type \tcode{Base}
1221-
}
1222-
\end{codeblock}
1223-
\end{example}
1224-
12251183
\pnum
12261184
\ubxref{class.dtor.no.longer.exists} \\
12271185
Once a destructor is invoked for an object, the object no longer exists; the behavior is undefined if the

0 commit comments

Comments
 (0)