Skip to content

Commit 2d2cfa0

Browse files
notadragonjoshuaberne
authored andcommitted
[ub] Add many missing entries to UB annex (#7864)
Co-authored-by: jberne4 <[email protected]>
1 parent fa7976d commit 2d2cfa0

File tree

6 files changed

+402
-32
lines changed

6 files changed

+402
-32
lines changed

source/basic.tex

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3734,7 +3734,7 @@
37343734
using the alignment specifier\iref{dcl.align}.
37353735
Attempting to create an object\iref{intro.object} in storage that
37363736
does not meet the alignment requirements of the object's type
3737-
is undefined behavior.
3737+
is undefined behavior.\ubdef{basic.align.object.alignment}
37383738

37393739
\pnum
37403740
A \defnadj{fundamental}{alignment} is represented by an alignment
@@ -4149,7 +4149,7 @@
41494149
\pnum
41504150
Except in the following cases,
41514151
if an indeterminate value is produced by an evaluation,
4152-
the behavior is undefined, and
4152+
the behavior is undefined\ubdef{basic.indet.value}, and
41534153
if an erroneous value is produced by an evaluation,
41544154
the behavior is erroneous and
41554155
the result of the evaluation is the value so produced but is not erroneous:
@@ -4476,7 +4476,7 @@
44764476
\tcode{p0} represents the address of a block of storage disjoint from the storage
44774477
for any other object accessible to the caller.
44784478
The effect of indirecting through a pointer
4479-
returned from a request for zero size is undefined.
4479+
returned from a request for zero size is undefined.\ubdef{basic.stc.alloc.zero.dereference}
44804480
\begin{footnote}
44814481
The intent is
44824482
to have \tcode{\keyword{operator} \keyword{new}()} implementable by
@@ -4599,7 +4599,7 @@
45994599
signature.
46004600

46014601
\pnum
4602-
If a deallocation function terminates by throwing an exception, the behavior is undefined.
4602+
If a deallocation function terminates by throwing an exception, the behavior is undefined.\ubdef{basic.stc.alloc.dealloc.throw}
46034603
The value of the first argument supplied to a deallocation function may
46044604
be a null pointer value; if so, and if the deallocation function is one
46054605
supplied in the standard library, the call has no effect.
@@ -5925,7 +5925,7 @@
59255925
$P$ is not valid in the context of $E$,
59265926
then the behavior is undefined if $E$ is
59275927
an indirection\iref{expr.unary.op} or
5928-
an invocation of a deallocation function\iref{basic.stc.dynamic.deallocation},
5928+
an invocation of a deallocation function\iref{basic.stc.dynamic.deallocation}\ubdef{basic.compound.invalid.pointer},
59295929
and \impldef{invalid pointer value in the context of an evaluation} otherwise.
59305930
\begin{footnote}
59315931
Some implementations might define that

source/classes.tex

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6103,9 +6103,10 @@
61036103
\indextext{destruction!member access}%
61046104
For an object with a non-trivial constructor, referring to any non-static member
61056105
or base class of the object before the constructor begins execution results in
6106-
undefined behavior\ubdef{class.cdtor.before.ctor.after.dtor}. For an object with a non-trivial destructor, referring to
6106+
undefined behavior\ubdef{class.cdtor.before.ctor}.
6107+
For an object with a non-trivial destructor, referring to
61076108
any non-static member or base class of the object after the destructor finishes
6108-
execution results in undefined behavior.
6109+
execution results in undefined behavior\ubdef{class.cdtor.after.dtor}.
61096110
\begin{example}
61106111
\begin{codeblock}
61116112
struct X { int i; };

source/declarations.tex

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3280,11 +3280,11 @@
32803280
the converted initializer is a glvalue whose
32813281
type is not call-compatible\iref{expr.call}
32823282
with the type of the function's definition
3283-
results in undefined behavior.
3283+
results in undefined behavior.\ubdef{dcl.ref.incompatible.function}
32843284
Attempting to bind a reference to an object where
32853285
the converted initializer is a glvalue through which
32863286
the object is not type-accessible\iref{basic.lval}
3287-
results in undefined behavior.
3287+
results in undefined behavior\ubdef{dcl.ref.incompatible.type}.
32883288
\begin{note}
32893289
\indextext{reference!null}%
32903290
The object designated by such a glvalue can be
@@ -3298,7 +3298,7 @@
32983298
\end{note}
32993299
The behavior of an evaluation of a reference\iref{expr.prim.id, expr.ref} that
33003300
does not happen after\iref{intro.races} the initialization of the reference
3301-
is undefined.
3301+
is undefined.\ubdef{dcl.ref.uninitialized.reference}
33023302
\begin{example}
33033303
\begin{codeblock}
33043304
int &f(int&);

source/expressions.tex

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@
323323
a defaulted copy/move constructor or copy/move assignment operator
324324
for a union of type \tcode{U} with a glvalue argument
325325
that does not denote an object of type \cv{}~\tcode{U} within its lifetime,
326-
the behavior is undefined.
326+
the behavior is undefined.\ubdef{expr.basic.lvalue.union.initialization}
327327
\begin{note}
328328
In C, an entire object of structure type can be accessed, e.g., using assignment.
329329
By contrast, \Cpp{} has no notion of accessing an object of class type
@@ -342,7 +342,7 @@
342342
If a pointer to $X$ would be valid in
343343
the context of the evaluation of the expression\iref{basic.fundamental},
344344
the result designates $X$;
345-
otherwise, the behavior is undefined.
345+
otherwise, the behavior is undefined.\ubdef{expr.type.reference.lifetime}
346346
\begin{note}
347347
Before the lifetime of the reference has started or after it has ended,
348348
the behavior is undefined (see~\ref{basic.life}).
@@ -683,7 +683,7 @@
683683

684684
\item Otherwise, if the bits in the value representation of
685685
the object to which the glvalue refers
686-
are not valid for the object's type, the behavior is undefined.
686+
are not valid for the object's type, the behavior is undefined.\ubdef{conv.lval.valid.representation}
687687
\begin{example}
688688
\begin{codeblock}
689689
bool f() {
@@ -996,7 +996,7 @@
996996
integer type. The conversion truncates; that is, the fractional part is
997997
discarded.
998998
\indextext{value!undefined unrepresentable integral}%
999-
The behavior is undefined\ubdef{conv.fpint.not.represented} if the truncated value cannot be represented
999+
The behavior is undefined\ubdef{conv.fpint.float.not.represented} if the truncated value cannot be represented
10001000
in the destination type.
10011001
\begin{note}
10021002
If the destination type is \keyword{bool}, see~\ref{conv.bool}.
@@ -1017,7 +1017,8 @@
10171017
exactly as a value of the floating-point type.
10181018
\end{note}
10191019
If the value being converted is
1020-
outside the range of values that can be represented, the behavior is undefined. If the
1020+
outside the range of values that can be represented, the behavior is undefined.\ubdef{conv.fpint.int.not.represented}
1021+
If the
10211022
source type is \keyword{bool}, the value \keyword{false} is converted to zero and the value
10221023
\keyword{true} is converted to one.
10231024

@@ -1069,7 +1070,7 @@
10691070
that is
10701071
within its lifetime or
10711072
within its period of construction or destruction\iref{class.cdtor},
1072-
the behavior is undefined.
1073+
the behavior is undefined.\ubdef{conv.ptr.virtual.base}
10731074
Otherwise,
10741075
the result is a pointer to the base class subobject of
10751076
the derived class object.
@@ -1103,7 +1104,8 @@
11031104
\tcode{D}, a program that necessitates this conversion is ill-formed.
11041105
If class \tcode{D} does not contain the original member and
11051106
is not a base class of the class containing the original member,
1106-
the behavior is undefined. Otherwise,
1107+
the behavior is undefined.\ubdef{conv.member.missing.member}
1108+
Otherwise,
11071109
the result of the conversion refers to the same member as the pointer to
11081110
member before the conversion took place, but it refers to the base class
11091111
member as if it were a member of the derived class. The result refers to
@@ -4354,7 +4356,7 @@
43544356
(possibly after overload resolution) and
43554357
the result of \tcode{E1} is an object whose type
43564358
is not similar\iref{conv.qual} to the type of \tcode{E1},
4357-
the behavior is undefined\ubdef{expr.ref.not.similar}.
4359+
the behavior is undefined\ubdef{expr.ref.member.not.similar}.
43584360
\begin{example}
43594361
\begin{codeblock}
43604362
struct A { int i; };
@@ -4490,7 +4492,7 @@
44904492
that is
44914493
within its lifetime or
44924494
within its period of construction or destruction,
4493-
the behavior is undefined.
4495+
the behavior is undefined.\ubdef{expr.dynamic.cast.lifetime}
44944496

44954497
\pnum
44964498
If \tcode{T} is ``pointer to \cv{} \keyword{void}'', then the result
@@ -4810,7 +4812,7 @@
48104812
the result of the conversion is
48114813
an \impldef{result of inexact floating-point conversion} choice of
48124814
either of those values.
4813-
Otherwise, the behavior is undefined\ubdef{expr.static.cast.downcast.wrong.derived.type}.
4815+
Otherwise, the behavior is undefined\ubdef{expr.static.cast.fp.outside.range}.
48144816

48154817
\pnum
48164818
\indextext{cast!base class}%
@@ -4831,7 +4833,7 @@
48314833
``pointer to \cvqual{cv1} \tcode{B}'' points to a \tcode{B} that is
48324834
actually a base class subobject of an object of type \tcode{D}, the resulting
48334835
pointer points to the enclosing object of type \tcode{D}. Otherwise, the
4834-
behavior is undefined.
4836+
behavior is undefined\ubdef{expr.static.cast.downcast.wrong.derived.type}.
48354837

48364838
\pnum
48374839
\indextext{cast!pointer-to-member}%
@@ -5236,7 +5238,8 @@
52365238
The operator yields an lvalue of type \tcode{T}.
52375239
If the operand points to an object or function,
52385240
the result denotes that object or function;
5239-
otherwise, the behavior is undefined except as specified in \ref{expr.typeid}.
5241+
otherwise, the behavior is undefined except as specified in \ref{expr.typeid}
5242+
\ubdef{expr.unary.dereference}.
52405243
\begin{note}
52415244
\indextext{type!incomplete}%
52425245
Indirection through a pointer to an incomplete type (other than
@@ -7228,7 +7231,7 @@
72287231
\pnum
72297232
For addition or subtraction, if the expressions \tcode{P} or \tcode{Q} have
72307233
type ``pointer to \cv{}~\tcode{T}'', where \tcode{T} and the array element type
7231-
are not similar\iref{conv.qual}, the behavior is undefined\ubdef{expr.add.polymorphic}.
7234+
are not similar\iref{conv.qual}, the behavior is undefined\ubdef{expr.add.not.similar}.
72327235
\begin{example}
72337236
\begin{codeblock}
72347237
int arr[5] = {1, 2, 3, 4, 5};

source/front.tex

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
\let\oindex\index
1818
\let\index\indexoff
1919

20+
\setcounter{tocdepth}{5}
21+
2022
%% Include table of contents. Do not list "Contents"
2123
%% within it (per ISO request) but do include a
2224
%% bookmark for it in the PDF.

0 commit comments

Comments
 (0)