Skip to content

Commit 7ff8cc1

Browse files
committed
[P3144] Deleting a pointer to incomplete type is illformed
1 parent 6d67d20 commit 7ff8cc1

File tree

2 files changed

+25
-3
lines changed

2 files changed

+25
-3
lines changed

source/compatibility.tex

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,29 @@
3333
\end{codeblock}
3434
\end{example}
3535

36+
37+
38+
\diffref{expr.delete}
39+
\change
40+
Calling \tcode{delete} on a pointer to an incomplete class is ill-formed.
41+
\rationale
42+
Reduce undefined behavior.
43+
\effect
44+
A valid \CppXXIII{} program that that calls \tcode{delete} on an incomplete
45+
class type becomes ill-formed.
46+
\begin{example}
47+
\begin{codeblock}
48+
struct S;
49+
50+
void f(S *p) {
51+
delete p; // valid in \CppXXIII{}, ill-formed in this document
52+
}
53+
54+
struct S {};
55+
\end{codeblock}
56+
\end{example}
57+
58+
3659
\rSec2[diff.cpp23.dcl.dcl]{\ref{dcl.dcl}: Declarations}
3760

3861
\diffref{dcl.init.list}

source/expressions.tex

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5839,9 +5839,8 @@
58395839

58405840
\pnum
58415841
\indextext{type!incomplete}%
5842-
If the object being deleted has incomplete class type at the point of
5843-
deletion and the complete class has a non-trivial destructor or a
5844-
deallocation function, the behavior is undefined.
5842+
If the object being deleted has incomplete class type at the point of deletion,
5843+
the program is ill-formed.
58455844

58465845
\pnum
58475846
\indextext{\idxcode{delete}!destructor and}%

0 commit comments

Comments
 (0)