Skip to content

Commit 1555db4

Browse files
committed
fixups: split out throwing deallocation function ub
1 parent 156b953 commit 1555db4

File tree

2 files changed

+23
-4
lines changed

2 files changed

+23
-4
lines changed

source/basic.tex

+1-1
Original file line numberDiff line numberDiff line change
@@ -4423,7 +4423,7 @@
44234423
signature.
44244424

44254425
\pnum
4426-
If a deallocation function terminates by throwing an exception, the behavior is undefined.\ubxref{basic.stc.alloc.dealloc.constraint.2}
4426+
If a deallocation function terminates by throwing an exception, the behavior is undefined.\ubxref{basic.stc.alloc.dealloc.throw}
44274427
The value of the first argument supplied to a deallocation function may
44284428
be a null pointer value; if so, and if the deallocation function is one
44294429
supplied in the standard library, the call has no effect.

source/ub.tex

+22-3
Original file line numberDiff line numberDiff line change
@@ -262,11 +262,9 @@
262262

263263
\pnum
264264
\ubxref{basic.stc.alloc.dealloc.constraint} \\
265-
% \ubxref{basic.stc.alloc.dealloc.constraint.2} \\
266265
If the behavior of an allocation or deallocation function does not satisfy the semantic constraints
267266
specified
268-
in \iref{basic.stc.dynamic.allocation} and \iref{basic.stc.dynamic.deallocation},
269-
including exiting via a thrown exception when not specified to do so,
267+
in \iref{basic.stc.dynamic.allocation} and \iref{basic.stc.dynamic.deallocation}.
270268
the behavior is undefined.
271269

272270

@@ -287,6 +285,27 @@
287285
\end{codeblock}
288286
\end{example}
289287

288+
\pnum
289+
\ubxref{basic.stc.alloc.dealloc.throw} \\
290+
If a call to a deallocation function
291+
terminates by throwing an exception
292+
the behavior is undefined.
293+
\pnum
294+
\begin{example}
295+
\begin{codeblock}
296+
struct X {
297+
void operator delete(void*) { throw "oops"; }
298+
};
299+
void f()
300+
{
301+
X* x = new X();
302+
delete x; // undefined behavior
303+
}
304+
\end{codeblock}
305+
\end{example}
306+
307+
308+
290309
\rSec2[ub.basic.stc.alloc.zero.dereference]{Zero-sized allocation dereference}
291310

292311
\pnum

0 commit comments

Comments
 (0)