@@ -594,7 +594,7 @@ impl f32 {
594
594
// However, std can't simply compare to zero to check for zero, either,
595
595
// as correctness requires avoiding equality tests that may be Subnormal == -0.0
596
596
// because it may be wrong under "denormals are zero" and "flush to zero" modes.
597
- // Most of std's targets don't use those, but they are used for thumbv7neon" .
597
+ // Most of std's targets don't use those, but they are used for thumbv7neon.
598
598
// So, this does use bitpattern matching for the rest.
599
599
600
600
// SAFETY: f32 to u32 is fine. Usually.
@@ -609,6 +609,12 @@ impl f32 {
609
609
// FIXME(jubilee): This probably could at least answer things correctly for Infinity,
610
610
// like the f64 version does, but I need to run more checks on how things go on x86.
611
611
// I fear losing mantissa data that would have answered that differently.
612
+ //
613
+ // # Safety
614
+ // This requires making sure you call this function for values it answers correctly on,
615
+ // otherwise it returns a wrong answer. This is not important for memory safety per se,
616
+ // but getting floats correct is important for not accidentally leaking const eval
617
+ // runtime-deviating logic which may or may not be acceptable.
612
618
#[ rustc_const_unstable( feature = "const_float_classify" , issue = "72505" ) ]
613
619
const unsafe fn partial_classify ( self ) -> FpCategory {
614
620
const EXP_MASK : u32 = 0x7f800000 ;
@@ -992,7 +998,7 @@ impl f32 {
992
998
// ...sorta.
993
999
//
994
1000
// It turns out that at runtime, it is possible for a floating point number
995
- // to be subject to a floating point mode that alters nonzero subnormal numbers
1001
+ // to be subject to floating point modes that alter nonzero subnormal numbers
996
1002
// to zero on reads and writes, aka "denormals are zero" and "flush to zero".
997
1003
// This is not a problem usually, but at least one tier2 platform for Rust
998
1004
// actually exhibits this behavior by default: thumbv7neon
0 commit comments