You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[APFloat] Prevent construction of APFloat with Semantics and FP value
Constructor invocations such as `APFloat(APFloat::IEEEdouble(), 0.0)`
may seem like they accept a FP (floating point) value, but the overload
they reach is actually the `integerPart` one, not a `float` or `double`
overload (which only exists when `fltSemantics` isn't passed).
This may lead to possible loss of data, by the conversion from `float`
or `double` to `integerPart`.
To prevent future mistakes, a new constructor overload, which accepts
any FP value and marked with `delete`, to prevent its usage.
Fixes PR34095.
Differential Revision: https://reviews.llvm.org/D70425
Copy file name to clipboardexpand all lines: llvm/unittests/ADT/APFloatTest.cpp
+13-13
Original file line number
Diff line number
Diff line change
@@ -520,9 +520,9 @@ TEST(APFloatTest, FMA) {
520
520
521
521
// Test x87 extended precision case from http://llvm.org/PR20728.
522
522
{
523
-
APFloat M1(APFloat::x87DoubleExtended(), 1.0);
524
-
APFloat M2(APFloat::x87DoubleExtended(), 1.0);
525
-
APFloat A(APFloat::x87DoubleExtended(), 3.0);
523
+
APFloat M1(APFloat::x87DoubleExtended(), 1);
524
+
APFloat M2(APFloat::x87DoubleExtended(), 1);
525
+
APFloat A(APFloat::x87DoubleExtended(), 3);
526
526
527
527
bool losesInfo = false;
528
528
M1.fusedMultiplyAdd(M1, A, APFloat::rmNearestTiesToEven);
0 commit comments