Skip to content

Commit ac9f449

Browse files
committed
[basic.life,basic.start.term,expr.delete] Clarify destruction of scalars
1 parent b6f5885 commit ac9f449

File tree

3 files changed

+20
-14
lines changed

3 files changed

+20
-14
lines changed

source/basic.tex

+12-11
Original file line numberDiff line numberDiff line change
@@ -3383,8 +3383,8 @@
33833383
program has undefined behavior if:
33843384
\begin{itemize}
33853385
\item
3386-
the object will be or was of a class type with a non-trivial destructor
3387-
and the pointer is used as the operand of a \grammarterm{delete-expression},
3386+
the pointer is used to destroy the object
3387+
(\ref{expr.prim.id.dtor}, \ref{expr.delete})
33883388
\item
33893389
the pointer is used to access a non-static data member or call a
33903390
non-static member function of the object, or
@@ -3447,6 +3447,7 @@
34473447
well-defined. The program has undefined behavior if:
34483448
\begin{itemize}
34493449
\item the glvalue is used to access the object, or
3450+
\item the glvalue is used to destroy the object\iref{expr.prim.id.dtor}, or
34503451
\item the glvalue is used to call a non-static member function of the object, or
34513452
\item the glvalue is bound to a reference to a virtual base class\iref{dcl.init.ref}, or
34523453
\item the glvalue is used as the operand of a
@@ -3516,17 +3517,17 @@
35163517
If a program ends the lifetime of an object of type \tcode{T} with
35173518
static\iref{basic.stc.static}, thread\iref{basic.stc.thread},
35183519
or automatic\iref{basic.stc.auto}
3519-
storage duration and if \tcode{T} has a non-trivial destructor,
3520+
storage duration,
35203521
\begin{footnote}
35213522
That
3522-
is, an object for which a destructor will be called
3523+
is, an object that is destroyed
35233524
implicitly---upon exit from the block for an object with
35243525
automatic storage duration, upon exit from the thread for an object with
35253526
thread storage duration, or upon exit from the program for an object
35263527
with static storage duration.
35273528
\end{footnote}
35283529
and another object of the original type does not occupy
3529-
that same storage location when the implicit destructor call takes
3530+
that same storage location when the implicit destruction takes
35303531
place, the behavior of the program is undefined. This is true
35313532
even if the block is exited with an exception.
35323533
\begin{example}
@@ -6633,11 +6634,11 @@
66336634

66346635
\pnum
66356636
If the completion of the constructor or dynamic initialization of an object with static
6636-
storage duration strongly happens before that of another, the completion of the destructor
6637-
of the second is sequenced before the initiation of the destructor of the first.
6637+
storage duration strongly happens before that of another, the completion of the destruction
6638+
of the second is sequenced before the initiation of the destruction of the first.
66386639
If the completion of the constructor or dynamic initialization of an object with thread
6639-
storage duration is sequenced before that of another, the completion of the destructor
6640-
of the second is sequenced before the initiation of the destructor of the first.
6640+
storage duration is sequenced before that of another, the completion of the destruction
6641+
of the second is sequenced before the initiation of the destruction of the first.
66416642
If an object is
66426643
initialized statically, the object is destroyed in the same order as if
66436644
the object was dynamically initialized. For an object of array or class
@@ -6665,9 +6666,9 @@
66656666
If the completion of the initialization of an object with static storage
66666667
duration strongly happens before a call to \tcode{std::atexit}~(see
66676668
\libheader{cstdlib}, \ref{support.start.term}), the call to the function passed to
6668-
\tcode{std::atexit} is sequenced before the call to the destructor for the object. If a
6669+
\tcode{std::atexit} is sequenced before the destruction of the object. If a
66696670
call to \tcode{std::atexit} strongly happens before the completion of the initialization of
6670-
an object with static storage duration, the call to the destructor for the
6671+
an object with static storage duration, the destruction of the
66716672
object is sequenced before the call to the function passed to \tcode{std::atexit}. If a
66726673
call to \tcode{std::atexit} strongly happens before another call to \tcode{std::atexit}, the
66736674
call to the function passed to the second \tcode{std::atexit} call is sequenced before

source/classes.tex

+5
Original file line numberDiff line numberDiff line change
@@ -2198,6 +2198,10 @@
21982198
construction (see~\ref{class.init}).
21992199

22002200
\pnum
2201+
\indextext{destroy}%
2202+
Whenever an object of class type is destroyed,
2203+
its destructor is invoked for that object.
2204+
\begin{note}
22012205
\indextext{destructor!implicit call}%
22022206
\indextext{destructor!program termination and}%
22032207
A destructor is invoked implicitly
@@ -2210,6 +2214,7 @@
22102214

22112215
\item for a constructed temporary object when its lifetime ends~(\ref{conv.rval}, \ref{class.temporary}).
22122216
\end{itemize}
2217+
\end{note}
22132218

22142219
\indextext{\idxcode{delete}!destructor and}%
22152220
\indextext{destructor!explicit call}%

source/expressions.tex

+3-3
Original file line numberDiff line numberDiff line change
@@ -5492,9 +5492,9 @@
54925492
null pointer value
54935493
and the selected deallocation function (see below)
54945494
is not a destroying operator delete,
5495-
the \grammarterm{delete-expression} will invoke the
5496-
destructor (if any) for the object or the elements of the array being
5497-
deleted. In the case of an array, the elements will be destroyed in
5495+
the \grammarterm{delete-expression} destroys the object or
5496+
the elements of the array being
5497+
deleted. In the case of an array, the elements are destroyed in
54985498
order of decreasing address (that is, in reverse order of the completion
54995499
of their constructor; see~\ref{class.base.init}).
55005500

0 commit comments

Comments
 (0)