Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 13307cb

Browse files
authored
[ub] small fixes to examples (#7890)
1 parent 35381f1 commit 13307cb

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

source/ub.tex

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -790,23 +790,20 @@
790790

791791
\pnum
792792
\begin{example}
793+
If \tcode{float} does not adhere to \IsoFloatUndated{}
794+
and cannot represent positive infinty,
795+
a sufficiently large \tcode{double} value will be
796+
outside the (finite) range of \tcode{float}.
793797
\begin{codeblock}
794798
void f() {
795-
double d = FLT_MAX * 16;
799+
double d = FLT_MAX;
796800
d *= 16;
797801
float f = static_cast<float>(d); // undefined behavior.
798802
}
799803
\end{codeblock}
800804
\end{example}
801805

802806

803-
\pnum
804-
\begin{example}
805-
\begin{codeblock}
806-
807-
\end{codeblock}
808-
\end{example}
809-
810807
\pnum
811808
\ubxref{expr.static.cast.downcast.wrong.derived.type} \\
812809
Down-casting to the wrong derived type is undefined behavior.
@@ -1347,7 +1344,8 @@
13471344
\begin{codeblock}
13481345
extern int &ir1;
13491346
int i2 = ir1; // undefined behavior, \tcode{ir1} not yet initialized
1350-
int ir1 = 17;
1347+
int i3 = 17;
1348+
int &ir1 = i3;
13511349
\end{codeblock}
13521350
\end{example}
13531351

@@ -1674,9 +1672,9 @@
16741672
}
16751673
void f()
16761674
{
1677-
X& px = &g();
1675+
X* px = &g();
16781676
px->~X();
1679-
int*p = px->i; // undefined behavior
1677+
int j = px->i; // undefined behavior
16801678
}
16811679
\end{codeblock}
16821680
\end{example}

0 commit comments

Comments
 (0)