diff --git a/source/ub.tex b/source/ub.tex index fa3e3f42a3..5dc126bab8 100644 --- a/source/ub.tex +++ b/source/ub.tex @@ -790,9 +790,13 @@ \pnum \begin{example} +If \tcode{float} does not adhere to \IsoFloatUndated{} +and cannot represent positive infinty, +a sufficiently large \tcode{double} value will be +outside the (finite) range of \tcode{float}. \begin{codeblock} void f() { - double d = FLT_MAX * 16; + double d = FLT_MAX; d *= 16; float f = static_cast(d); // undefined behavior. } @@ -800,13 +804,6 @@ \end{example} -\pnum -\begin{example} -\begin{codeblock} - -\end{codeblock} -\end{example} - \pnum \ubxref{expr.static.cast.downcast.wrong.derived.type} \\ Down-casting to the wrong derived type is undefined behavior. @@ -1347,7 +1344,8 @@ \begin{codeblock} extern int &ir1; int i2 = ir1; // undefined behavior, \tcode{ir1} not yet initialized -int ir1 = 17; +int i3 = 17; +int &ir1 = i3; \end{codeblock} \end{example} @@ -1674,9 +1672,9 @@ } void f() { - X& px = &g(); + X* px = &g(); px->~X(); - int*p = px->i; // undefined behavior + int j = px->i; // undefined behavior } \end{codeblock} \end{example}