Skip to content

[ub] a few more fixes #7888

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: ub-ifndr
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions source/basic.tex
Original file line number Diff line number Diff line change
Expand Up @@ -3504,7 +3504,7 @@
and produce a pointer value that points to that object,
if that value would result in the program having defined behavior.
If no such pointer value would give the program defined behavior,
the behavior of the program is undefined.
the behavior of the program is undefined\ubdef{intro.object.implicit.pointer}.
If multiple such pointer values would give the program defined behavior,
it is unspecified which such pointer value is produced.

Expand Down Expand Up @@ -3748,27 +3748,27 @@
if the pointer were of type \tcode{\keyword{void}*} is
well-defined. Indirection through such a pointer is permitted but the resulting lvalue may only be used in
limited ways, as described below. The
program has undefined behavior\ubdef{lifetime.outside.pointer} if:
program has undefined behavior if:
\begin{itemize}
\item
the pointer is used as the operand of a \grammarterm{delete-expression},
the pointer is used as the operand of a \grammarterm{delete-expression}\ubdef{lifetime.outside.pointer.delete},
\item
the pointer is used to access a non-static data member or call a
non-static member function of the object, or
non-static member function of the object\ubdef{lifetime.outside.pointer.member}, or
\item
the pointer is implicitly converted\iref{conv.ptr} to a pointer
to a virtual base class, or
to a virtual base class\ubdef{lifetime.outside.pointer.virtual}, or
\item
the pointer is used as the operand of a
\keyword{static_cast}\iref{expr.static.cast}, except when the conversion
\keyword{static_cast}\iref{expr.static.cast}\ubdef{lifetime.outside.pointer.static.cast}, except when the conversion
is to pointer to \cv{}~\keyword{void}, or to pointer to \cv{}~\keyword{void}
and subsequently to pointer to
\cv{}~\keyword{char},
\cv{}~\tcode{\keyword{unsigned} \keyword{char}}, or
\cv{}~\tcode{std::byte}\iref{cstddef.syn}, or
\item
the pointer is used as the operand of a
\keyword{dynamic_cast}\iref{expr.dynamic.cast}.
\keyword{dynamic_cast}\iref{expr.dynamic.cast}\ubdef{lifetime.outside.pointer.dynamic.cast}.
\end{itemize}
\begin{example}
\begin{codeblock}
Expand Down Expand Up @@ -3811,14 +3811,14 @@
a glvalue refers to
allocated storage\iref{basic.stc.dynamic.allocation}, and using the
properties of the glvalue that do not depend on its value is
well-defined. The program has undefined behavior\ubdef{lifetime.outside.glvalue} if:
well-defined. The program has undefined behavior if:
\begin{itemize}
\item the glvalue is used to access the object, or
\item the glvalue is used to call a non-static member function of the object, or
\item the glvalue is bound to a reference to a virtual base class\iref{dcl.init.ref}, or
\item the glvalue is used to access the object\ubdef{lifetime.outside.glvalue.access}, or
\item the glvalue is used to call a non-static member function of the object\ubdef{lifetime.outside.glvalue.member}, or
\item the glvalue is bound to a reference to a virtual base class\iref{dcl.init.ref}\ubdef{lifetime.outside.glvalue.virtual}, or
\item the glvalue is used as the operand of a
\keyword{dynamic_cast}\iref{expr.dynamic.cast} or as the operand of
\keyword{typeid}.
\keyword{typeid}\ubdef{lifetime.outside.glvalue.dynamic.cast}.
\end{itemize}

\begin{note}
Expand Down
4 changes: 2 additions & 2 deletions source/classes.tex
Original file line number Diff line number Diff line change
Expand Up @@ -6123,15 +6123,15 @@
indirectly derive from
\tcode{B}
shall have started and the destruction of these classes shall not have
completed, otherwise the conversion results in undefined behavior.
completed, otherwise the conversion results in undefined behavior\ubdef{class.cdtor.convert.pointer}.
To form a pointer to (or access the value of) a direct non-static member of
an object
\tcode{obj},
the construction of
\tcode{obj}
shall have started and its destruction shall not have completed,
otherwise the computation of the pointer value (or accessing the member
value) results in undefined behavior\ubdef{class.cdtor.convert.or.form.pointer}.
value) results in undefined behavior\ubdef{class.cdtor.form.pointer}.
\begin{example}
\begin{codeblock}
struct A { };
Expand Down
8 changes: 4 additions & 4 deletions source/expressions.tex
Original file line number Diff line number Diff line change
Expand Up @@ -1019,7 +1019,7 @@
\end{note}
If the value being converted is
outside the range of values that can be represented, the behavior is undefined.
% \ubdef{conv.fpint.int.not.represented}
\ubdef{conv.fpint.int.not.represented}
If the
source type is \keyword{bool}, the value \keyword{false} is converted to zero and the value
\keyword{true} is converted to one.
Expand Down Expand Up @@ -4199,14 +4199,14 @@
that is
within its lifetime or
within its period of construction or destruction\iref{class.cdtor},
the behavior is undefined.
the behavior is undefined.\ubdef{expr.dynamic.cast.pointer.lifetime}
If \tcode{v} is a glvalue of type \tcode{U} and
\tcode{v} does not refer to an object
whose type is similar to \tcode{U} and
that is
within its lifetime or
within its period of construction or destruction,
the behavior is undefined.\ubdef{expr.dynamic.cast.lifetime}
the behavior is undefined.\ubdef{expr.dynamic.cast.glvalue.lifetime}

\pnum
If \tcode{T} is ``pointer to \cv{} \keyword{void}'', then the result
Expand Down Expand Up @@ -6156,7 +6156,7 @@
element of the array created by that \grammarterm{new-expression}.
Zero-length arrays do not have a first element.
\end{footnote}
If not, the behavior is undefined.
If not, the behavior is undefined\ubdef{expr.delete.array.mismatch}.
\begin{note}
This means that the syntax of the \grammarterm{delete-expression} must
match the type of the object allocated by \keyword{new}, not the syntax of the
Expand Down
Loading
Loading