Skip to content

Commit 5f96fe9

Browse files
authored
Unrolled build for rust-lang#136296
Rollup merge of rust-lang#136296 - RalfJung:float-min-max, r=tgross35 float::min/max: mention the non-determinism around signed 0 Turns out this can actually produce different results on different machines [in practice](rust-lang#83984 (comment)); that seems worth documenting. I assume LLVM will happily const-fold these operations so so there could be different results for the same input even on the same machine, depending on whether things get const-folded or not. `@nikic` I remember there was an LLVM soundness fix regarding scalar evolution for loops that had to recognize certain operations as non-deterministic... it seems to me that pass would also have to avoid predicting the result of `llvm.{min,max}num`, for the same reason? r? `@tgross35` Cc `@rust-lang/libs-api` If this lands we should also make Miri non-deterministic here. Fixes rust-lang#83984
2 parents c37fbd8 + 6b699cc commit 5f96fe9

File tree

4 files changed

+16
-8
lines changed

4 files changed

+16
-8
lines changed

library/core/src/num/f128.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -670,7 +670,8 @@ impl f128 {
670670
/// If one of the arguments is NaN, then the other argument is returned.
671671
/// This follows the IEEE 754-2008 semantics for maxNum, except for handling of signaling NaNs;
672672
/// this function handles all NaNs the same way and avoids maxNum's problems with associativity.
673-
/// This also matches the behavior of libm’s fmax.
673+
/// This also matches the behavior of libm’s fmax. In particular, if the inputs compare equal
674+
/// (such as for the case of `+0.0` and `-0.0`), either input may be returned non-deterministically.
674675
///
675676
/// ```
676677
/// #![feature(f128)]
@@ -696,7 +697,8 @@ impl f128 {
696697
/// If one of the arguments is NaN, then the other argument is returned.
697698
/// This follows the IEEE 754-2008 semantics for minNum, except for handling of signaling NaNs;
698699
/// this function handles all NaNs the same way and avoids minNum's problems with associativity.
699-
/// This also matches the behavior of libm’s fmin.
700+
/// This also matches the behavior of libm’s fmin. In particular, if the inputs compare equal
701+
/// (such as for the case of `+0.0` and `-0.0`), either input may be returned non-deterministically.
700702
///
701703
/// ```
702704
/// #![feature(f128)]

library/core/src/num/f16.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -662,7 +662,8 @@ impl f16 {
662662
/// If one of the arguments is NaN, then the other argument is returned.
663663
/// This follows the IEEE 754-2008 semantics for maxNum, except for handling of signaling NaNs;
664664
/// this function handles all NaNs the same way and avoids maxNum's problems with associativity.
665-
/// This also matches the behavior of libm’s fmax.
665+
/// This also matches the behavior of libm’s fmax. In particular, if the inputs compare equal
666+
/// (such as for the case of `+0.0` and `-0.0`), either input may be returned non-deterministically.
666667
///
667668
/// ```
668669
/// #![feature(f16)]
@@ -687,7 +688,8 @@ impl f16 {
687688
/// If one of the arguments is NaN, then the other argument is returned.
688689
/// This follows the IEEE 754-2008 semantics for minNum, except for handling of signaling NaNs;
689690
/// this function handles all NaNs the same way and avoids minNum's problems with associativity.
690-
/// This also matches the behavior of libm’s fmin.
691+
/// This also matches the behavior of libm’s fmin. In particular, if the inputs compare equal
692+
/// (such as for the case of `+0.0` and `-0.0`), either input may be returned non-deterministically.
691693
///
692694
/// ```
693695
/// #![feature(f16)]

library/core/src/num/f32.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -874,7 +874,8 @@ impl f32 {
874874
/// If one of the arguments is NaN, then the other argument is returned.
875875
/// This follows the IEEE 754-2008 semantics for maxNum, except for handling of signaling NaNs;
876876
/// this function handles all NaNs the same way and avoids maxNum's problems with associativity.
877-
/// This also matches the behavior of libm’s fmax.
877+
/// This also matches the behavior of libm’s fmax. In particular, if the inputs compare equal
878+
/// (such as for the case of `+0.0` and `-0.0`), either input may be returned non-deterministically.
878879
///
879880
/// ```
880881
/// let x = 1.0f32;
@@ -895,7 +896,8 @@ impl f32 {
895896
/// If one of the arguments is NaN, then the other argument is returned.
896897
/// This follows the IEEE 754-2008 semantics for minNum, except for handling of signaling NaNs;
897898
/// this function handles all NaNs the same way and avoids minNum's problems with associativity.
898-
/// This also matches the behavior of libm’s fmin.
899+
/// This also matches the behavior of libm’s fmin. In particular, if the inputs compare equal
900+
/// (such as for the case of `+0.0` and `-0.0`), either input may be returned non-deterministically.
899901
///
900902
/// ```
901903
/// let x = 1.0f32;

library/core/src/num/f64.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -892,7 +892,8 @@ impl f64 {
892892
/// If one of the arguments is NaN, then the other argument is returned.
893893
/// This follows the IEEE 754-2008 semantics for maxNum, except for handling of signaling NaNs;
894894
/// this function handles all NaNs the same way and avoids maxNum's problems with associativity.
895-
/// This also matches the behavior of libm’s fmax.
895+
/// This also matches the behavior of libm’s fmax. In particular, if the inputs compare equal
896+
/// (such as for the case of `+0.0` and `-0.0`), either input may be returned non-deterministically.
896897
///
897898
/// ```
898899
/// let x = 1.0_f64;
@@ -913,7 +914,8 @@ impl f64 {
913914
/// If one of the arguments is NaN, then the other argument is returned.
914915
/// This follows the IEEE 754-2008 semantics for minNum, except for handling of signaling NaNs;
915916
/// this function handles all NaNs the same way and avoids minNum's problems with associativity.
916-
/// This also matches the behavior of libm’s fmin.
917+
/// This also matches the behavior of libm’s fmin. In particular, if the inputs compare equal
918+
/// (such as for the case of `+0.0` and `-0.0`), either input may be returned non-deterministically.
917919
///
918920
/// ```
919921
/// let x = 1.0_f64;

0 commit comments

Comments
 (0)