Skip to content

Commit a09e5e8

Browse files
joshuabernenotadragon
authored andcommitted
[ub] added many missing entries to UB annex
1 parent 0788337 commit a09e5e8

File tree

6 files changed

+354
-27
lines changed

6 files changed

+354
-27
lines changed

source/basic.tex

+4-4
Original file line numberDiff line numberDiff line change
@@ -3558,7 +3558,7 @@
35583558
using the alignment specifier\iref{dcl.align}.
35593559
Attempting to create an object\iref{intro.object} in storage that
35603560
does not meet the alignment requirements of the object's type
3561-
is undefined behavior.
3561+
is undefined behavior.\ubdef{basic.align.object.alignment}
35623562

35633563
\pnum
35643564
A \defnadj{fundamental}{alignment} is represented by an alignment
@@ -3973,7 +3973,7 @@
39733973
\pnum
39743974
Except in the following cases,
39753975
if an indeterminate value is produced by an evaluation,
3976-
the behavior is undefined, and
3976+
the behavior is undefined\ubdef{basic.indet.value}, and
39773977
if an erroneous value is produced by an evaluation,
39783978
the behavior is erroneous and
39793979
the result of the evaluation is the value so produced but is not erroneous:
@@ -4300,7 +4300,7 @@
43004300
\tcode{p0} represents the address of a block of storage disjoint from the storage
43014301
for any other object accessible to the caller.
43024302
The effect of indirecting through a pointer
4303-
returned from a request for zero size is undefined.
4303+
returned from a request for zero size is undefined.\ubdef{basic.stc.alloc.zero.dereference}
43044304
\begin{footnote}
43054305
The intent is
43064306
to have \tcode{\keyword{operator} \keyword{new}()} implementable by
@@ -4423,7 +4423,7 @@
44234423
signature.
44244424

44254425
\pnum
4426-
If a deallocation function terminates by throwing an exception, the behavior is undefined.
4426+
If a deallocation function terminates by throwing an exception, the behavior is undefined.\ubxref{basic.stc.alloc.dealloc.constraint.2}
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/classes.tex

+3-2
Original file line numberDiff line numberDiff line change
@@ -6035,9 +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.after.dtor}. For an object with a non-trivial destructor, referring to
6038+
undefined behavior\ubdef{class.cdtor.before.ctor.before.ctor}.
6039+
For an object with a non-trivial destructor, referring to
60396040
any non-static member or base class of the object after the destructor finishes
6040-
execution results in undefined behavior.
6041+
execution results in undefined behavior\ubdef{class.cdtor.before.ctor.after.dtor}.
60416042
\begin{example}
60426043
\begin{codeblock}
60436044
struct X { int i; };

source/declarations.tex

+3-3
Original file line numberDiff line numberDiff line change
@@ -3185,11 +3185,11 @@
31853185
the converted initializer is a glvalue whose
31863186
type is not call-compatible\iref{expr.call}
31873187
with the type of the function's definition
3188-
results in undefined behavior.
3188+
results in undefined behavior.\ubdef{dcl.ref.incompatible.function}
31893189
Attempting to bind a reference to an object where
31903190
the converted initializer is a glvalue through which
31913191
the object is not type-accessible\iref{basic.lval}
3192-
results in undefined behavior.
3192+
results in undefined behavior\ubdef{dcl.ref.incompatible.type}.
31933193
\begin{note}
31943194
\indextext{reference!null}%
31953195
The object designated by such a glvalue can be
@@ -3203,7 +3203,7 @@
32033203
\end{note}
32043204
The behavior of an evaluation of a reference\iref{expr.prim.id, expr.ref} that
32053205
does not happen after\iref{intro.races} the initialization of the reference
3206-
is undefined.
3206+
is undefined.\ubdef{dcl.ref.uninitialized.reference}
32073207
\begin{example}
32083208
\begin{codeblock}
32093209
int &f(int&);

source/expressions.tex

+14-11
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@
322322
a defaulted copy/move constructor or copy/move assignment operator
323323
for a union of type \tcode{U} with a glvalue argument
324324
that does not denote an object of type \cv{}~\tcode{U} within its lifetime,
325-
the behavior is undefined.
325+
the behavior is undefined.\ubdef{expr.basic.lvalue.union.initialization}
326326
\begin{note}
327327
In C, an entire object of structure type can be accessed, e.g., using assignment.
328328
By contrast, \Cpp{} has no notion of accessing an object of class type
@@ -341,7 +341,7 @@
341341
If a pointer to $X$ would be valid in
342342
the context of the evaluation of the expression\iref{basic.fundamental},
343343
the result designates $X$;
344-
otherwise, the behavior is undefined.
344+
otherwise, the behavior is undefined.\ubdef{expr.type.reference,lifetime}
345345
\begin{note}
346346
Before the lifetime of the reference has started or after it has ended,
347347
the behavior is undefined (see~\ref{basic.life}).
@@ -680,7 +680,7 @@
680680

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

@@ -1070,7 +1071,7 @@
10701071
that is
10711072
within its lifetime or
10721073
within its period of construction or destruction\iref{class.cdtor},
1073-
the behavior is undefined.
1074+
the behavior is undefined.\ubdef{conv.ptr.virtual.base}
10741075
Otherwise,
10751076
the result is a pointer to the base class subobject of
10761077
the derived class object.
@@ -1104,7 +1105,8 @@
11041105
\tcode{D}, a program that necessitates this conversion is ill-formed.
11051106
If class \tcode{D} does not contain the original member and
11061107
is not a base class of the class containing the original member,
1107-
the behavior is undefined. Otherwise,
1108+
the behavior is undefined.\ubdef{conv.member.missing.member}
1109+
Otherwise,
11081110
the result of the conversion refers to the same member as the pointer to
11091111
member before the conversion took place, but it refers to the base class
11101112
member as if it were a member of the derived class. The result refers to
@@ -4203,7 +4205,7 @@
42034205
that is
42044206
within its lifetime or
42054207
within its period of construction or destruction,
4206-
the behavior is undefined.
4208+
the behavior is undefined.\ubdef{expr.dynamic.cast.lifetime}
42074209

42084210
\pnum
42094211
If \tcode{T} is ``pointer to \cv{} \keyword{void}'', then the result
@@ -4549,7 +4551,7 @@
45494551
the result of the conversion is
45504552
an \impldef{result of inexact floating-point conversion} choice of
45514553
either of those values.
4552-
Otherwise, the behavior is undefined\ubdef{expr.static.cast.downcast.wrong.derived.type}.
4554+
Otherwise, the behavior is undefined\ubdef{expr.static.cast.fp.outside.range}.
45534555

45544556
\pnum
45554557
\indextext{cast!base class}%
@@ -4570,7 +4572,7 @@
45704572
``pointer to \cvqual{cv1} \tcode{B}'' points to a \tcode{B} that is
45714573
actually a base class subobject of an object of type \tcode{D}, the resulting
45724574
pointer points to the enclosing object of type \tcode{D}. Otherwise, the
4573-
behavior is undefined.
4575+
behavior is undefined\ubdef{expr.static.cast.downcast.wrong.derived.type}.
45744576

45754577
\pnum
45764578
\indextext{cast!pointer-to-member}%
@@ -4977,7 +4979,8 @@
49774979
The operator yields an lvalue of type \tcode{T}.
49784980
If the operand points to an object or function,
49794981
the result denotes that object or function;
4980-
otherwise, the behavior is undefined except as specified in \ref{expr.typeid}.
4982+
otherwise, the behavior is undefined except as specified in \ref{expr.typeid}
4983+
\ubdef{expr.unary.dereference}.
49814984
\begin{note}
49824985
\indextext{type!incomplete}%
49834986
Indirection through a pointer to an incomplete type (other than

source/front.tex

+2
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)