Annex F
(informative)
Core undefined behavior
[ub]
F.3
Clause [expr]: Expressions
[ub.expr]
F.3.31
[ub:expr.add.sub.pointers.rep]
Specified in:
[expr.
add]
1
#
Subtracting two expressions of pointer type where the difference is not representable in
std
::
ptrdiff_
t
has undefined behavior
.
2
#
[
Example
1
:
char
big
[
static_cast
<
std
::
uintmax_t
>
(
PTRDIFF_MAX
)
+
1
]
; std
::
ptrdiff_t d
=
(
big
+
sizeof
(
big
)
-
big
)
;
// undefined behavior
—
end example
]