Skip to content

Commit 4589b64

Browse files
authored
Merge 2024-06 CWG Motion 5
P3144R2 Deleting a Pointer to an Incomplete Type Should be Ill-formed
2 parents 9f97a8c + cdabb16 commit 4589b64

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

source/compatibility.tex

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

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

3858
\diffref{dcl.init.list}

source/expressions.tex

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

58545854
\pnum
58555855
\indextext{type!incomplete}%
5856-
If the object being deleted has incomplete class type at the point of
5857-
deletion and the complete class has a non-trivial destructor or a
5858-
deallocation function, the behavior is undefined.
5856+
If the object being deleted has incomplete class type at the point of deletion,
5857+
the program is ill-formed.
58595858

58605859
\pnum
58615860
\indextext{\idxcode{delete}!destructor and}%

0 commit comments

Comments
 (0)