Skip to content

Commit 4dd7d1d

Browse files
committed
fixups: cleanups suggested by timur
1 parent a27ded1 commit 4dd7d1d

File tree

4 files changed

+31
-9
lines changed

4 files changed

+31
-9
lines changed

source/basic.tex

+1-1
Original file line numberDiff line numberDiff line change
@@ -5634,7 +5634,7 @@
56345634
$P$ is not valid in the context of $E$,
56355635
then the behavior is undefined if $E$ is
56365636
an indirection\iref{expr.unary.op} or
5637-
an invocation of a deallocation function\iref{basic.stc.dynamic.deallocation},
5637+
an invocation of a deallocation function\iref{basic.stc.dynamic.deallocation}\ubdef{basic.compound.invalid.pointer},
56385638
and \impldef{invalid pointer value in the context of an evaluation} otherwise.
56395639
\begin{footnote}
56405640
Some implementations might define that

source/classes.tex

+2-2
Original file line numberDiff line numberDiff line change
@@ -6035,10 +6035,10 @@
60356035
\indextext{destruction!member access}%
60366036
For an object with a non-trivial constructor, referring to any non-static member
60376037
or base class of the object before the constructor begins execution results in
6038-
undefined behavior\ubdef{class.cdtor.before.ctor.before.ctor}.
6038+
undefined behavior\ubdef{class.cdtor.before.ctor}.
60396039
For an object with a non-trivial destructor, referring to
60406040
any non-static member or base class of the object after the destructor finishes
6041-
execution results in undefined behavior\ubdef{class.cdtor.before.ctor.after.dtor}.
6041+
execution results in undefined behavior\ubdef{class.cdtor.after.dtor}.
60426042
\begin{example}
60436043
\begin{codeblock}
60446044
struct X { int i; };

source/expressions.tex

+2-2
Original file line numberDiff line numberDiff line change
@@ -4069,7 +4069,7 @@
40694069
If \tcode{E2} is a non-static member and
40704070
the result of \tcode{E1} is an object whose type
40714071
is not similar\iref{conv.qual} to the type of \tcode{E1},
4072-
the behavior is undefined\ubdef{expr.ref.not.similar}.
4072+
the behavior is undefined\ubdef{expr.ref.member.not.similar}.
40734073
\begin{example}
40744074
\begin{codeblock}
40754075
struct A { int i; };
@@ -6734,7 +6734,7 @@
67346734
\pnum
67356735
For addition or subtraction, if the expressions \tcode{P} or \tcode{Q} have
67366736
type ``pointer to \cv{}~\tcode{T}'', where \tcode{T} and the array element type
6737-
are not similar\iref{conv.qual}, the behavior is undefined\ubdef{expr.add.polymorphic}.
6737+
are not similar\iref{conv.qual}, the behavior is undefined\ubdef{expr.add.not.similar}.
67386738
\begin{example}
67396739
\begin{codeblock}
67406740
int arr[5] = {1, 2, 3, 4, 5};

source/ub.tex

+26-4
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,28 @@
305305
\end{codeblock}
306306
\end{example}
307307

308+
\rSec2[ub.basic.compound]{Compound types}
309+
310+
\pnum
311+
\ubxref{basic.compound.invalid.pointer] \\
312+
Indirection or
313+
the invocation of a deallocation function
314+
with an invalid pointer value
315+
has undefined behavior.
316+
317+
\pnum
318+
\begin{example}
319+
\begin{codeblock}
320+
void f()
321+
{
322+
int *x = new int{5};
323+
delete x;
324+
int y = *x; // undefined behavior
325+
delete x; // undefined behavior
326+
}
327+
\end{codeblock}
328+
\end{example}
329+
308330

309331
\rSec2[ub.intro.execution]{Sequential execution}
310332

@@ -660,7 +682,7 @@
660682
\rSec2[ub.expr.ref]{Class member access}
661683

662684
\pnum
663-
\ubxref{expr.ref.not.similar} \\
685+
\ubxref{expr.ref.member.not.similar} \\
664686
If \tcode{E2} is a non-static member and the result of \tcode{E1} is an object whose type
665687
is not similar\iref{conv.qual} to the type of \tcode{E1}, the behavior is undefined.
666688

@@ -1053,7 +1075,7 @@
10531075
\end{example}
10541076

10551077
\pnum
1056-
\ubxref{expr.add.polymorphic} \\
1078+
\ubxref{expr.add.not.similar} \\
10571079
For addition or subtraction, if the expressions P or Q have type ``pointer to cv T'', where T and the array
10581080
element type are not similar \iref{conv.rval}, the behavior is undefined.
10591081

@@ -1558,7 +1580,7 @@
15581580
\rSec2[ub.class.cdtor]{Construction and destruction}
15591581

15601582
\pnum
1561-
\ubxref{class.cdtor.before.ctor.before.ctor} \\
1583+
\ubxref{class.cdtor.before.ctor} \\
15621584
For an object with a non-trivial constructor, referring to any non-static member or base class of the object
15631585
before the constructor begins execution results in undefined behavior. For an object with a non-trivial
15641586
destructor, referring to any non-static member or base class of the object after the destructor finishes execution
@@ -1608,7 +1630,7 @@
16081630

16091631

16101632
\pnum
1611-
\ubxref{class.cdtor.before.ctor.after.dtor} \\
1633+
\ubxref{class.cdtor.after.dtor} \\
16121634
For an object with a non-trivial destructor,
16131635
referring to any non-static member or base class of the object
16141636
after the destructor finishes execution

0 commit comments

Comments
 (0)